DATA Step, Macro, Functions and more

How can i not create a dataset if a variable is completely blank

Reply
Regular Contributor
Posts: 165

How can i not create a dataset if a variable is completely blank

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;
Highlighted
Super User
Super User
Posts: 8,174

Re: How can i not create a dataset if a variable is completely blank

Hi,

 

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.  

Super User
Posts: 11,554

Re: How can i not create a dataset if a variable is completely blank

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 &macrodatasetname;" I can't make any reasonable targeted suggestions in response to your specific question.

 

 

Ask a Question
Discussion stats
  • 2 replies
  • 76 views
  • 0 likes
  • 3 in conversation