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

So I calculated the totals as such: 

 

 proc sql noprint;
 select sum(A_N_ALL) into :EthnicA trimmed from catdem where CAT = 1;
 select sum(B_N_ALL) into :EthnicB trimmed from catdem where CAT = 1;
 select sum(A_N_ALL) into :RaceA trimmed from catdem where CAT = 2;
 select sum(B_N_ALL) into :RaceB trimmed from catdem where CAT = 2;
 select sum(A_N_OBESE) into :ObeseA trimmed from catdem where CAT = 1;
 select sum(B_N_OBESE) into :ObeseB trimmed from catdem where CAT = 1;
 select sum(A_N_NOT_OBESE) into :NotObeseA trimmed from catdem where CAT = 1;
 select sum(B_N_NOT_OBESE) into :NotObeseB trimmed from catdem where CAT = 1;
 select sum(A_N_SEVERELY_OBESE) into :SeverelyObeseA trimmed from catdem where CAT = 1;
 select sum(B_N_SEVERELY_OBESE) into :SeverelyObeseB trimmed from catdem where CAT = 1;
run;

With these results in the log:

 

 

3397 %put &=EthnicA &=RaceA &=EthnicB &=RaceB; /*totals match up*/
ETHNICA=120 RACEA=120 ETHNICB=20 RACEB=20
3398 %put &=ObeseA &=ObeseB &=NotObeseA &=NotObeseB $=SeverelyObeseA &=SeverelyObeseB;
OBESEA=24 OBESEB=2 NOTOBESEA=58 NOTOBESEB=12 $=SeverelyObeseA SEVERELYOBESEB=6

Now I want these totals to show up in the column titles when I run PROC REPORT.

 

Code:

proc report data = catdem nowd split = '*'
 %reportStyle

 column CAT CHAR 
	('Cohort A' ('BMI < 30 *kg/m ^{super 2} ^n (N = &&NotObeseA)' A_N_NOT_OBESE A_P_NOT_OBESE) ('30 ^{unicode 2264} BMI ^{unicode 2264}*kg/m ^{super 2} ^n (N = &&ObeseA)' A_N_OBESE A_P_OBESE) ('BMI > 40 *kg/m ^{super 2} ^n (N = &&SeverelyObeseA)' A_N_SEVERELY_OBESE A_P_SEVERELY_OBESE) ('All Subjects (N = &&EhtnicA)' A_N_ALL A_P_ALL))
	('Cohort B' ('BMI < 30 *kg/m ^{super 2} ^n (N = &&NotObeseB)' B_N_NOT_OBESE B_P_NOT_OBESE) ('30 ^{unicode 2264} BMI ^{unicode 2264}*kg/m ^{super 2} ^n (N = &&ObeseB)' B_N_OBESE B_P_OBESE) ('BMI > 40 *kg/m ^{super 2} ^n (N = &&SeverelyObeseB)' B_N_SEVERELY_OBESE B_P_SEVERELY_OBESE) ('All Subjects (N = &&EhtnicB)' B_N_ALL B_P_ALL));
...

When I do this, I get N = &&NotObeseA, etc. instead of N = 58. What can I do to fix this?

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Macro variables do not resolve inside single quotes. Replace the quotes around macro variables with " quotes.

 

 ("BMI < 30 *kg/m ^{super 2} ^n (N = &&NotObeseA)" 

 

View solution in original post

1 REPLY 1
ballardw
Super User

Macro variables do not resolve inside single quotes. Replace the quotes around macro variables with " quotes.

 

 ("BMI < 30 *kg/m ^{super 2} ^n (N = &&NotObeseA)" 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 481 views
  • 4 likes
  • 2 in conversation