DATA Step, Macro, Functions and more

Creating a column heading from a variable and text

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

Creating a column heading from a variable and text

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

 


Accepted Solutions
Solution
‎09-05-2016 01:08 AM
Super User
Posts: 19,855

Re: Creating a column heading from a variable and text

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


All Replies
Solution
‎09-05-2016 01:08 AM
Super User
Posts: 19,855

Re: Creating a column heading from a variable and text

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;
Occasional Contributor
Posts: 15

Re: Creating a column heading from a variable and text

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

Respected Advisor
Posts: 4,930

Re: Creating a column heading from a variable and text

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

PG
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 238 views
  • 0 likes
  • 3 in conversation