BookmarkSubscribeRSS Feed
monday89
Fluorite | Level 6

I have two datasets

dataset #1: by group

group_assigneddenominator
placebo10
treatment12

 

dataset #2: 

Demographicstreatmentplacebo
Age  
Gender  
Race  
Medications  

 

the treatment groups changes every data export so i want to set n=# for each group. For this export, something like this:

 

Demographicstreatment (n=12)placebo (n=10)
Age  
Gender  
Race  
Medications  

 

I tried %macro but i think it is not working

3 REPLIES 3
Reeza
Super User
Show what you've tried please.
andreas_lds
Jade | Level 19

Please clearify the target format of the export and show the code you are using. I don't macro-code is required to solve the problem, i would use labels. The following step adds labels to the variables in dataset work.two.

 

data _null_;
	set groups end=last;
	
	if _n_ = 1 then do;
		call execute('proc datasets library=work nolist;');
		call execute('modify two;');
		call execute('label');
	end;
	
	call execute(cats(group_assigned, '=', quote(catx(' ', group_assigned, '(n=', denominator, ')'))));
	
	if last then do;
		call execute(';');
		call execute('quit;');
	end;
run;
Reeza
Super User

See Example 8 here

https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/173-2008.pdf

 

The link in the document to the code shows exactly how to do it.

http://support.sas.com/rnd/papers/sgf2008/complex_reports.zip

 


@monday89 wrote:

I have two datasets

dataset #1: by group

group_assigned denominator
placebo 10
treatment 12

 

dataset #2: 

Demographics treatment placebo
Age    
Gender    
Race    
Medications    

 

the treatment groups changes every data export so i want to set n=# for each group. For this export, something like this:

 

Demographics treatment (n=12) placebo (n=10)
Age    
Gender    
Race    
Medications    

 

I tried %macro but i think it is not working


 

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