How do I access a specific row and column from a dataset and save it to a global variable for later use? for example from sashelp.cars dataset how do I get first row value for 'Make' column?
%macro ExtractACell(rownum=1, VarName='Make');
data work.TempDelete;
set sashelp.cars;
if _n_ = &rownum then
do;
%global MyVar;
MyVar = ????? *Code to get the Make value from the first row and save to MyVar
end;
run;
%mend ExtractACell;
%put &MyVar *<-- Is this correct
You’re missing the CALL SYMPUTX() to create the macro variable. YOu may want to also use the FIRSTOBS and OBS data set options to read only a single line.
Ready to join fellow brilliant minds for the SAS Hackathon?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.