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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1069 views
  • 2 likes
  • 2 in conversation