Hi, all:
I have a macro statement created by a previous coworker. Could anyone explain what the "call symputx" part and the "if" condition after "call symputx" are for? Thanks.
Y
%macro list(lib,sect);
data §.c;
set §.a(rename=(name=name_sup));
stabb=scan(name_sup,1,"_");
run;
data _null_;
set §.c end=eof;
by name_sup;
j+1;
call symputx("name"||trim(left(put(j,8.))),name_sup,'G');
call symputx("stabb"||trim(left(put(j,8.))),stabb,'G');
if eof then call symputx("count_state",j,'G');
run;
%mend list;
if eof
tests when you have reached the very last observation of the SAS data set you are processing
call symputx
creates a global macro variable named "count_state" from the value of the data set variable j in that last observation
if eof
tests when you have reached the very last observation of the SAS data set you are processing
call symputx
creates a global macro variable named "count_state" from the value of the data set variable j in that last observation
What is the following for?
call symputx("name"||trim(left(put(j,8.))),name_sup,'G');
@ybz12003 wrote:
What is the following for?
call symputx("name"||trim(left(put(j,8.))),name_sup,'G');
creating a series macro variables
Name1 , Name2, Name3 etc holding the values for variable Name_sup for each record in the input data set.
What is the 'G' for?
Did you read the documentation?
Thanks, I just read through it.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.