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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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