BookmarkSubscribeRSS Feed
riccardo88
Calcite | Level 5

Hallo everybody,

 

I´m plotting my data and I would like to show 4 variable as percentage of another variable.

 

My data:

 

Unbenannt.png

 

My Code:

 

proc sgplot data=Transposed_average_hz;
scatter x=frequency y=col1;
scatter x=frequency y=col2;
scatter x=frequency y=col3;
scatter x=frequency y=col4;
scatter x=frequency y=col5;
run;

 

What I would like to have (sort of)...

ex.png

Thank you very much for your help!

6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

What four variables do your want to plot? And what variable should they represent percentages of?

riccardo88
Calcite | Level 5

COL 2,3,4,5 as percentage of COL1.

 

COL1 should be a straight line in the graphic.

PeterClemmensen
Tourmaline | Level 20

Ok. Can you post your data in a usable form (Not a picture)?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Looks like Excel thinking again.  Get your data looking like:
COL    PCENT   FREQUENCY

1         ...             ...

....

 

Then use:

proc sgplot data=Transposed_average_hz;
  series x=frequency y=pcent / group=col;
run;

Note, as you said you want a line, then series is most likely. 

Ksharp
Super User

Your code look good. add option "curvelabel"

 

proc sgplot data=Transposed_average_hz;
scatter x=frequency y=col1/curvelabel ;
scatter x=frequency y=col2/curvelabel;
scatter x=frequency y=col3/curvelabel;
scatter x=frequency y=col4/curvelabel;
scatter x=frequency y=col5/curvelabel;
run;
Rick_SAS
SAS Super FREQ

Sort by the X variable and use the SERIES statement:

 

proc sort data=Transposed_average_hz;
by frequency;
run;

proc sgplot data=Transposed_average_hz;
series x=frequency y=col1 / curvelabel;
series x=frequency y=col2 / curvelabel;
series x=frequency y=col3 / curvelabel;
series x=frequency y=col4 / curvelabel;
series x=frequency y=col5 / curvelabel;
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 6 replies
  • 959 views
  • 2 likes
  • 5 in conversation