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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.