BookmarkSubscribeRSS Feed
cvilme1998
Fluorite | Level 6

I was trying to categorize values in sashelp.bweight like below so I can make this graph:

ccpday.png

Infant Weight Category Definition:

Value range

Category Label

Less than 3000 g

low

Between 3000 g and 3500 g (inclusively)

below average

Greater than 3500 g and less than or equal to 4000 g

above average

Over 4000 g

high

 

 

Attempted this code, but I got too many outputs and it was not as clean as the graph I was aiming for above. Is there a way to improve this code or an easier code to try?

 

proc format; value weight
low-<3000= "Low"
3000<=x<=3500= "Below Average"
3500>=90000= "Above Average"
4000>high "High"; Run;


proc freq data=sashelp.bweight; table weight*cigsperday;
format weight weight. cigsperday cigsperday.;
ods output CrossTabFreqs=work.sasbweight; run;
ods listing;


proc sgplot data=sashelp.bweight;
ods graphics on/discretemax=2500;
hbar weight. / response=cigsperday. group=momedlevel groupdisplay=cluster;
xaxis label="Cigarettes Per Day" grid gridattrs=(color=gray66)
values=(0 to 4 by 1);
yaxis label="Infant Birth Weight";
keylegend / position = bottom;
run;

1 REPLY 1
PGStats
Opal | Level 21

With proper syntax:

 

proc format; value weight
low-3000 = "Low"
3000-3500 = "Below Average"
3500-4000 = "Above Average"
4000-high = "High"; 
Run;

proc sgplot data=sashelp.bweight;
format weight weight.;
hbar weight / response=cigsperday group=momedlevel groupdisplay=cluster 
    stat=mean limitstat=stderr limits=upper;
xaxis label="Cigarettes Per Day" grid gridattrs=(color=gray66)
    values=(0 to 4 by 1) offsetmax=0.15;
yaxis label="Infant Birth Weight";
keylegend / position = bottom;
run;

PGStats_0-1608847978307.png

 

 

PG

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 489 views
  • 1 like
  • 2 in conversation