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.