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

I want to create a bar chart using sas code with data as below with sgplot. 

 

PROC SGPLOT DATA = applications;

VBAR sys / RESPONSE = app;

VBAR sys / RESPONSE = env;

RUN;

 

Sys     app     env

 

a           67       45

b           20       54

c           35       60

d           40       78

 

Screen Shot 2018-04-22 at 2.57.16 PM.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

1. Transform your data to a long format so that you have three variables: SYS, MEASUREMENT_TYPE (APP/ENV), Value (measurement).

 

SYS, Measurement_Type, Value

 

2. Sort

 

3. Use VBAR, GROUP = Measurement_Type and GroupDisplay=Cluster. 

 

If this doesn't work for you, post your code. 

I did test it and this does generate the graph indicated. 

 


@radha009 wrote:

I want to create a bar chart using sas code with data as below with sgplot. 

 

PROC SGPLOT DATA = applications;

VBAR sys / RESPONSE = app;

VBAR sys / RESPONSE = env;

RUN;

 

Sys     app     env

 

a           67       45

b           20       54

c           35       60

d           40       78

 

Screen Shot 2018-04-22 at 2.57.16 PM.png

 

 


 

View solution in original post

3 REPLIES 3
Reeza
Super User

1. Transform your data to a long format so that you have three variables: SYS, MEASUREMENT_TYPE (APP/ENV), Value (measurement).

 

SYS, Measurement_Type, Value

 

2. Sort

 

3. Use VBAR, GROUP = Measurement_Type and GroupDisplay=Cluster. 

 

If this doesn't work for you, post your code. 

I did test it and this does generate the graph indicated. 

 


@radha009 wrote:

I want to create a bar chart using sas code with data as below with sgplot. 

 

PROC SGPLOT DATA = applications;

VBAR sys / RESPONSE = app;

VBAR sys / RESPONSE = env;

RUN;

 

Sys     app     env

 

a           67       45

b           20       54

c           35       60

d           40       78

 

Screen Shot 2018-04-22 at 2.57.16 PM.png

 

 


 

radha009
Quartz | Level 8

Got it. but how do i transform the data. should i create new table and insert the data.

Reeza
Super User

@radha009 wrote:

Got it. but how do i transform the data. should i create new table and insert the data.


PROC TRANSPOSE or data step using an array. Tutorials below:

How to reshape data wide to long using proc transpose | SAS ...

Reshaping data wide to long using a data step | SAS ... - Stats at UCLA

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
  • 3 replies
  • 990 views
  • 0 likes
  • 2 in conversation