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

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! 

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

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;

 

 

image.png

Thanks,
Jag

View solution in original post

5 REPLIES 5
strugglingwsas
Fluorite | Level 6

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!).

Jagadishkatam
Amethyst | Level 16

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;

image.png

Thanks,
Jag
strugglingwsas
Fluorite | Level 6

Hello,

Thank you for your response. This helped a lot. Is there some way to graphically do this same thing?

Jagadishkatam
Amethyst | Level 16

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;

 

 

image.png

Thanks,
Jag
strugglingwsas
Fluorite | Level 6

Thank you! This worked. I really appreciate your help!

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 Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1230 views
  • 2 likes
  • 2 in conversation