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.

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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