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

Hallo!

I would need some help to create a Graph with my data.

The dataset looks like this:

data have;                    
   input ID $ co2 $ area area_under area_over;      
   datalines; 
101 High 329274.45563 1161.4533333 328113.0023
101 Low 329807.07976 51867.348667 277939.7311
103 High 299940.79867 1437.205 298503.59367
103 Low 309707.27464 196061.47517 113645.79948
105 High 500296.11766 32079.163619 468216.95404
105 Low 330042.631 69774.392944 260268.23805;            
Run;

and the graphS I would like to obtain like this:

 

N.1

time under 90 percent.png

 

where I have two vBars (one for every co2 level) and the blue part rapresent the percentage area_over/area and the red part rapresent the percentage area_under/area.

If possible I would also like to have a standard deviation bar.

 

 

N.2

 

The second Graph I would like to have looks like this

Unbenannt.png

 

 

Thank you very much for your help!

 

Riccardo

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Try the following and see if they meet your needs:

 

data have;
   input ID $ co2 $ area area_under area_over;
   datalines;
101 High 329274.45563 1161.4533333 328113.0023
101 Low 329807.07976 51867.348667 277939.7311
103 High 299940.79867 1437.205 298503.59367
103 Low 309707.27464 196061.47517 113645.79948
105 High 500296.11766 32079.163619 468216.95404
105 Low 330042.631 69774.392944 260268.23805
;
Run;

data have_neg;
set have;
area_under = -1 * area_under;
run;

proc format;
proc format;
picture posval low-high='000,009';
run;

proc sgplot data=have;
yaxis label="Area";
vbar co2 / response=area_under stat=mean limitstat=stddev discreteoffset=-0.2 barwidth=0.4;
vbar co2 / response=area_over  stat=mean limitstat=stddev discreteoffset=0.2 barwidth=0.4;
run;

proc sgplot data=have_neg;
format area_under posval.;
xaxis label="Area";
hbar co2 / response=area_under stat=mean;
hbar co2 / response=area_over  stat=mean;
run;

Hope this helps!
Dan

View solution in original post

2 REPLIES 2
ballardw
Super User

Where do the 0 and 1 come from for the first graph???

 

It looks like as at least one step you need something like:

data have;                    
   input ID $ co2 $ area area_under area_over;  
   under =   area_under/area;
   over  =   area_over /area;
   datalines; 
101 High 329274.45563 1161.4533333 328113.0023
101 Low 329807.07976 51867.348667 277939.7311
103 High 299940.79867 1437.205 298503.59367
103 Low 309707.27464 196061.47517 113645.79948
105 High 500296.11766 32079.163619 468216.95404
105 Low 330042.631 69774.392944 260268.23805
;            
Run;

(Note: the semicolon to end a datalines block must be after the last line of data)

Or perhaps you intend to sum the area, area_under and area_over and then do the percentages. But I can't tell which.

 

 

DanH_sas
SAS Super FREQ

Try the following and see if they meet your needs:

 

data have;
   input ID $ co2 $ area area_under area_over;
   datalines;
101 High 329274.45563 1161.4533333 328113.0023
101 Low 329807.07976 51867.348667 277939.7311
103 High 299940.79867 1437.205 298503.59367
103 Low 309707.27464 196061.47517 113645.79948
105 High 500296.11766 32079.163619 468216.95404
105 Low 330042.631 69774.392944 260268.23805
;
Run;

data have_neg;
set have;
area_under = -1 * area_under;
run;

proc format;
proc format;
picture posval low-high='000,009';
run;

proc sgplot data=have;
yaxis label="Area";
vbar co2 / response=area_under stat=mean limitstat=stddev discreteoffset=-0.2 barwidth=0.4;
vbar co2 / response=area_over  stat=mean limitstat=stddev discreteoffset=0.2 barwidth=0.4;
run;

proc sgplot data=have_neg;
format area_under posval.;
xaxis label="Area";
hbar co2 / response=area_under stat=mean;
hbar co2 / response=area_over  stat=mean;
run;

Hope this helps!
Dan

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1285 views
  • 0 likes
  • 3 in conversation