Hello,
I am trying to do an analysis using SAS University on data very similar to the sample data attached. The goal of the analysis is to show the change in the number_people by year for each project of each org_id or org_name (in organized tables like the ones shown in the sample data files and, if possible, a graph). I'm not sure how to do this on SAS, so I really appreciate all your help!
You may try the below code
data have;
input year org_name$ project$ number_people;
cards;
2015 ab ef 3
2015 ab gh 5
2015 ac hi 7
2016 ab ef 4
2016 ab gh 5
2016 ac hi 8
2016 ad jk 2
;
data want;
set have;
groups=catx('_',org_name,project);
run;
proc sgplot data=want;
vbar year / response=number_people group=groups;
run;
I forgot to mention that I did try to use proc freq to look at the number of times an observation was used for a specific project, but did not get the desired result (I'm pretty new to data analysis using SAS, I apologize!).
please try the below code
data have;
input year org_name$ project$ number_people;
cards;
2015 ab ef 3
2015 ab gh 5
2015 ac hi 7
2016 ab ef 4
2016 ab gh 5
2016 ac hi 8
2016 ad jk 2
;
proc sort data=have;
by org_name project;
run;
proc transpose data=have out=want;
by org_name project;
id year;
var number_people;
run;
PROC REPORT DATA=WORK.WANT LS=132 PS=60 SPLIT="/" CENTER ;
COLUMN org_name project _2015 _2016;
DEFINE org_name / group FORMAT= $8. WIDTH=8 SPACING=2 LEFT "org_name" ;
DEFINE project / group FORMAT= $8. WIDTH=8 SPACING=2 LEFT "project" ;
DEFINE _2015 / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "2015" ;
DEFINE _2016 / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "2016" ;
break after org_name/skip;
RUN;
Hello,
Thank you for your response. This helped a lot. Is there some way to graphically do this same thing?
You may try the below code
data have;
input year org_name$ project$ number_people;
cards;
2015 ab ef 3
2015 ab gh 5
2015 ac hi 7
2016 ab ef 4
2016 ab gh 5
2016 ac hi 8
2016 ad jk 2
;
data want;
set have;
groups=catx('_',org_name,project);
run;
proc sgplot data=want;
vbar year / response=number_people group=groups;
run;
Thank you! This worked. I really appreciate your help!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.