Is there a way to bring the value from a PROC FREQ output dataset into a PROC REPORT header?
For ex:
proc freq data=data;
tables cohort/out=cohortct (drop=percent rename=count=cohortct);
run;
data cohortct;
set cohortct;
cohortct2=strip(cohort||' (N='||(strip(cohortct)||')'));
put cohortct2;
run;
I need to display COHORTCT2 in a column header in PROC REPORT.
This is the value of COHORTCT2
1A (N=4)
1B (N=7)
proc report data=table1 split="|" ;
column cohort number1 ;
define cohort/display center style(column)={width=1in} 'Cohort I need the numbers for COHORTCT here';
define number1 /display right style(column)={width=.5in} 'Subjects experiencing Grade 1';
run;
How can this be done?
How about
data COHORTCT;
set COHORTCT;
COHORTCT2=strip(COHORT||' (N='||(strip(COHORTCT)||')'));
call symputx ('cohortct2',COHORTCT2);
run;
proc report data=TABLE1 split="|" ;
column COHORT NUMBER1 ;
define COHORT/display center style(column)={width= 1in} "Cohort &cohortct2";
define NUMBER1/display right style(column)={width=.5in} 'Subjects experiencing Grade 1';
run;
?
Did you copy the code as is? Including the double quotes?
You are right. The double quote did work - but the problem is it only keeps the second row.
I need
1A (N=4)
1B (N=7)
on the column header. But it only shows the second row, 1B (N=7).
Do you know why?
it only keeps the second row. Do you know why?
Because that's what you programmed.
I reckon the easiest is for you to create two macro variables
if _N_=1 then call symput...
if _N_=2 then call symput...
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.