in the below code if condition should not be executed but how i was able to print n varible value?
data _null_;
if -2 then set sashelp.class nobs=n;
call symput ('nrows',n);
run;
Two reasons:
The last reason is why you can get away with stuff like this:
data test;
do i=1 to n;
set x.data1 nobs=n;
output;
end;
run;So the N variable is defined and set before the loop which contains the SET statement begins execution.
All SET statements are always executed at compile time to to build the pdv, the IF -statement prevents execution at runtime, so that no observations are read.
Because the n variable in nobs=n is set at compile time
Two reasons:
The last reason is why you can get away with stuff like this:
data test;
do i=1 to n;
set x.data1 nobs=n;
output;
end;
run;So the N variable is defined and set before the loop which contains the SET statement begins execution.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.