I had 0 experience with SAS at the beginning of this month, but I've done pretty well on figuring things out over the last 3 weeks, except this...
We have a lovely proc report that I wrote, which lists students by level and age. The output is as follows:
Class Level is "Undergraduate" or "Graduate"
Age Group is <=18, 19-34, >=35
%Level Total should be filled in with the percentage of [Level] students who are 15 years old, 16, 17, etc. like so
proc sort data=stud;
by rpt_age_sort rpt_age;
run;
title1 c=blue h=2 'Student Age & Gender';
Title2 c=Black "&comp_semester to &semester";
ods proclabel 'Student Age';
proc report data=stud nowindows out=dual split='*';
column (levl_desc rpt_age_group rpt_age) term_code_key, (gender N percnt) ;
define levl_desc / right group order=data 'Class Level';
break after levl_desc /summarize skip OL style=[font_weight=bold background=Ligr];
define rpt_age_group / right group order=data 'Age Group';
break after rpt_age_group /summarize skip OL style=[font_weight=bold background=Ligr];
define rpt_age / right group order=data 'Age';
define gender / right group across format=$gender. 'Gender';
define term_code_key / format=$cester. center group across order=data 'Semester' STYLE={font_weight=bold foreground=blue};;
define n / center 'Total Students' style=[background=libgr font_weight=bold];
define percnt /computed center format=percent8.1 "% Level Total" style=[background=libgr font_weight=bold];
rbreak after /summarize skip DOL style=[background=Ligr font_weight=bold] ;
compute percnt;
percnt=levl_desc/count;
endcomp;
run;
I've tried searching everywhere I can to find an example that matches my case, but none of them are exactly fitting. I know now that my compute is a little wonky because i'm trying to use levl_desc as part of the calculation, but it's a text value... I'm brand new, don't judge!
Any help or advice would be greatly appreciated. I'm about as new as you can be when it comes to working with SAS, and most of the work I'll do in SAS is center around grouping stuff in proc report and generating percentages, so any advice would be GREATLY appreciated.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.