BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chris_e
Obsidian | Level 7

The following code checks whether an exposure value is less than 0 or . and if it is makes it 0. It then puts this into a new field called Raw_Agg_ and whatever the user puts in the variable cov, but I am unable to get SAS to create a new column header out of Raw_Agg_ and the macro variable cov

 

%macro expo_check(exposure_field, cov);
	
	if &exposure_field. < 0 or &exposure_field. = . then Raw_Agg_ || &cov. = 0;
		run;
%mend;

 

Any help would be greatly appreciated.

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You don't need the concatenation operator.

 

%macro expo_check(exposure_field, cov);
	
	if &exposure_field. < 0 or &exposure_field. = . then Raw_Agg_&cov. = 0;
		run;
%mend;

View solution in original post

3 REPLIES 3
Reeza
Super User

You don't need the concatenation operator.

 

%macro expo_check(exposure_field, cov);
	
	if &exposure_field. < 0 or &exposure_field. = . then Raw_Agg_&cov. = 0;
		run;
%mend;
chris_e
Obsidian | Level 7

Thanks, that was easy I was trying all sorts of other complicated stuff.

PGStats
Opal | Level 21

You probably don't need the run statement either. It should reside in the calling scope.

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 827 views
  • 0 likes
  • 3 in conversation