SAS Macro: How to Retrieve a Value from a Dataset

December 24, 2009 by
Filed under: Uncategorized 

SAS is a very powerful language when one have to deal with processing huge datasets. It becomes much more complicated when one wants to play with single elements. I recently had the need to put a specific value of a dataset into a macro variable. With the help of the SAS support team of Switzerland, I have made a small macro for that. Here is the definition of the function:

  • Macro name: Get_data
  • Input: myDataset (name of the dataset), myLine (line number), myColumn (name of the column), myMVar (name of the macro variable used to store the result)
  • Output: A new macro variable named &myMVar.

And here is the corresponding code:

%MACRO Get_data(myDataset=,myLine=,myColumn=,myMVar=);
%GLOBAL &myMVar.;
data _null_;
set &myDataset.;
if _N_ = &myLine. then do;
call symput(symget('myMVar'),&myColumn.);
end;
run;
%MEND Get_data;

Of course, I would be very interested if someone found a simplier way of performing this action (and I think SAS support would be interested as well).

Share

Comments

101 Comments on SAS Macro: How to Retrieve a Value from a Dataset

  1. evelina on Mon, 13th Feb 2017 2:25 pm
  2. Good everyone.
    My name Mrs, Jessica Phillips, i am from USA CA , i am married, i have been searching for a genuine loan company for the past 2 years and all i got was bunch of scams who made me to trust them and at the end of the day, the took all my money and left me Money less, all my hope was lost, i got confused and frustrated, i lost my job and find it very difficult to feed my family, i never wanted to do anything will loan companies on net anymore, so went to borrow some money from a friend, i told her all that happened and she said that she can help me, that she knows a loan company that can help me, that she just got a loan from them, he directed me on how to apply for the loan, i did as he told me, i applied, i never believed but i tried and to my surprise i got the loan in 24 hours, i could not believe my eyes, i am happy and rich today and i am thanking God that such loan companies like this still exist upon this fraud stars all over the places, please i advise everyone out there who are in need of loan to go for Mr. William Walker . Email via ; (believeloancompany@gmail.com). he did not know am doing this for him,but i just have to do it because a lost of people are out there who are in need for a loan., they will never fails, your life shall change as mine did.

    Thanks and Good Luck.

Tell me what you're thinking...





  • Swiss Association for Analytics

  • Most Popular Posts

  • T-shirts, Mugs & Mousepads


    All benefits given to a charity association
  • Data Mining Search Engine

    Supported by AnalyticBridge

  • Archives

  • Reading Recommandations