%LET statements are never part of a DATA step. You might as well have coded:
%let switch = N;
%let switch = 'Y';
%put &switch;
data _NULL_;
if rand('UNIFORM') > 0.3 then do;
end;
run;
That reflects what your program is actually doing. However, the good news is that there are interfaces between a DATA step and macro language. You could instead code:
%let switch = N;
data _null_;
if rand('UNIFORM') > 0.3 then call symput('switch', 'Y');
run;
%put &switch;
Two problems: 1 you change it from N to 'Y' (why do you add quotes for Y?)
2 You use %let let in a datastep, when you should use call symput
What condition do you really want to use? Surely, not just randomly like shown in your code.
Art, CEO, AnalystFinder.com
%LET statements are never part of a DATA step. You might as well have coded:
%let switch = N;
%let switch = 'Y';
%put &switch;
data _NULL_;
if rand('UNIFORM') > 0.3 then do;
end;
run;
That reflects what your program is actually doing. However, the good news is that there are interfaces between a DATA step and macro language. You could instead code:
%let switch = N;
data _null_;
if rand('UNIFORM') > 0.3 then call symput('switch', 'Y');
run;
%put &switch;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.