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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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