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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.