12-07-2017 06:20 AM
How can i not create a dataset if a variable is completely blank.
I am looping my program to create multiple datasets and i want to create a condition like if a particular macro variable is blank than not to create that dataset.
Any help? i tried %goto exit but it didnt work
%if &suppvar_list. ne %then %goto exit; %else %if; %** Loop through each variable thats being pushed to SUPP **; %if %sysevalf(%superq(suppvar_list) ne,boolean) %then %do j = 1 %to %sysfunc(countw(&suppvar_list.)); %let curr_var = %scan(&suppvar_list., &j.); if not missing(&curr_var.) then do; QNAM = upcase(vname(&curr_var.)); %** Look-up to get a label **; rc = _hhSUPP.find(key:QNAM); if rc ^= 0 then do; QLABEL = vlabel(&curr_var.); end; QVAL = &curr_var.; output; end; %end; %**if suppvar_list is missing then QNAM, QORIG, QEVAL should be blank; %else %do; %do j = 1 %to %sysfunc(countw(&suppvar_list,%str())); %let curr_var = %scan(&suppvar_list., &j.); call missing(QNAM, QORIG, QEVAL); %end; %end; %end;
12-07-2017 06:25 AM
I think we have beedn over this time and time again. Continuing down the route you are going is not in anyway ideal - i.e. insisting on using macro for everything, splitting data up into lots of datasets, looping, etc. They are all consistent with bad process.
12-07-2017 10:57 AM
I would ask how and why you create a blank macro variable in the first place.
Since your code snippet is an incomplete macro referencing macro variables without any example value, specifying which macro variable is blank when, or showing any code related to actually creating a data set (such as "data ¯odatasetname;" I can't make any reasonable targeted suggestions in response to your specific question.