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

I would like to create a horizontal bar chart that charts time in days. The x-axis would be total days. The bars would be the sum of 4 different times or phases, and color coded by phase. For example, building S3677 below would have a bar totaling 215 days, with each phase color coded within that bar.

The data is formatted like this:

Building    phase1     phase2     phase3     phase4

S212          201          165           35               46

O254         198           144          120            58

S3677        100           25            36             54

Any suggestions?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

First, transpose you data so that it looks like this:

Building     Value     Phase

S212          201       Phase1

S212          165       Phase2

S212          35         Phase3

S212          46         Phase4

...and so on.

Then, run either PROC SGPLOT or PROC GCHART:

proc sgplot data=buildings;

vbar building / response=value group=phase;

run;

proc gchart data=buildings;

vbar building / sumvar=value subgroup=phase;

run;

quit;

Hope this helps!

Dan

View solution in original post

4 REPLIES 4
DanH_sas
SAS Super FREQ

First, transpose you data so that it looks like this:

Building     Value     Phase

S212          201       Phase1

S212          165       Phase2

S212          35         Phase3

S212          46         Phase4

...and so on.

Then, run either PROC SGPLOT or PROC GCHART:

proc sgplot data=buildings;

vbar building / response=value group=phase;

run;

proc gchart data=buildings;

vbar building / sumvar=value subgroup=phase;

run;

quit;

Hope this helps!

Dan

sarahsasuser
Quartz | Level 8

Thanks Dan. Your answer made me realize that I need help with proc transpose more than the plotting procedures. I do not get the dataset I want when I do proc transpose data=have out=want; id building; var _all_; run;

Can you suggest a better way to transpose than I have?

PGStats
Opal | Level 21

This should do the trick

proc transpose data=have out=want(rename=(col1=value)) name=phase;

by building notsorted;

var phase: ;

run;

PG

PG
sarahsasuser
Quartz | Level 8

Thanks PGStats!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 938 views
  • 4 likes
  • 3 in conversation