BookmarkSubscribeRSS Feed
vraj1
Quartz | Level 8

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;
2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.  

ballardw
Super User

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.

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1068 views
  • 0 likes
  • 3 in conversation