Hi everyone!
I have 1000 tables 100gb each. I am processing them one by one with simple data steps.
I want to write an if statement that would check the first row, and if column X is not equal to 1 then stop this data step (meaning stop to work with this dataset) and go to the next table.
Thanks!
if x ne 1 then stop;
Are you positive X is an integer? If not then you might need to add some fuzz.
if -1E5 <= x-1 <= 1E5 then stop;
if x ne 1 then stop;
Are you positive X is an integer? If not then you might need to add some fuzz.
if -1E5 <= x-1 <= 1E5 then stop;
Question: Are you going to produce a single dataset from all the qualifying datasets, or must you create one dataset for each qualifying dataset?
If the answer is "create 1 dataset from all qualifying datasets", then you could process all 1,000 in a single step:
data want (drop=_:);
set have: curobs=cobs indsname=dsnam;
retain _skipdata ' ';
if cobs=1 then _skipdata=ifc(x^=1,'Y','N');
if _skipdata='N';
sourcedsn=dsnam;
*** Your other code here ***;
run;
Notes:
But if you want one output data set for each qualifying input dataset (i.e. you want work.new_have1 from work.have1, work.new_have4 from work.have4), then you could:
%macro t (indsn=,outdsn=)/ des='Code to apply to each dataset';
data &outdsn;
set &indsn;
*** other code here ***;
run;
%mend t;
data _null_;
set have: (obs=1 keep=x) curobs=cobs indsname=dsname ;
if x=1;
outdsn='new_' || scan(dsname,2,'.');
call execute(cats('*%t(indsn=',dsname,',outdsn=',outdsn,');'));
run;
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.