BookmarkSubscribeRSS Feed
aczech2001
Calcite | Level 5

Hi to all,

I need to change values of the 'cause' from the axis values from 1,2,3,4,5 to 1=Trauma, 2= Vascular with Diabetes, 3= Vascular without diabetes', 4=Oncologic. Ideally, I would like to also assign the right gender to the columns (1=male, 2=female, for the Gender variable).

 

This is the code that I have so far:

ods graphics / reset width=6.4in height=4.8in imagemap;

proc sgplot data=MEDSTUD.STRIDE_T;
vbar Cause / group=Gender groupdisplay=cluster fillattrs=(transparency=0.75)
datalabel stat=percent;
yaxis grid;
run;

ods graphics / reset;

 

Please, could you highlight in your answer the changes?

 

I attach the data set in the attachments.

 

Would you keep the same code to rename of the values in the same way, if you were to produce the table of frequencies? if not, please, could you post an example as well?

 

Thank you again for everyone's support!

 

Best regards,

 

Agnieszka (a complete newbie to SAS)

 

2 REPLIES 2
Ksharp
Super User

1) make a format and format it :

 

proc format;

value fmt

1='Trauma'

2=' Vascular'

.........;

run;

 

proc sgplot.......

.......

format Cause fmt.;

run;

 

2) using values=()  option:

proc sgplot data=MEDSTUD.STRIDE_T;
vbar Cause / group=Gender groupdisplay=cluster fillattrs=(transparency=0.75)
datalabel stat=percent;
xaxis values=('Trauma'  'Vascular ' ..............);
run;

 

GraphGuy
Meteorite | Level 14

Here's a little more complete code, in case you need it, followed by the sample output:

 

proc import out=stride_t datafile='u:\Socket18Data.xlsx' dbms=xlsx;
run;

 

proc format;
value gen_fmt
1="Male"
2="Female"
;
value causefmt
1="Trauma"
2="Vascular with Diabetes"
3="Vascular without Diabetes"
4="Oncologic"
;
run;


ods graphics / reset width=6.4in height=4.8in imagemap;

proc sgplot data=STRIDE_T;
format gender gen_fmt.;
format cause causefmt.;
vbar Cause / group=Gender groupdisplay=cluster fillattrs=(transparency=0.75)
datalabel stat=percent;
yaxis grid;
run;

ods graphics / reset;

 

onc.png

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1385 views
  • 3 likes
  • 3 in conversation