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...
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.