Hallo everybody,
I´m plotting my data and I would like to show 4 variable as percentage of another variable.
My data:
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)...
Thank you very much for your help!
What four variables do your want to plot? And what variable should they represent percentages of?
COL 2,3,4,5 as percentage of COL1.
COL1 should be a straight line in the graphic.
Ok. Can you post your data in a usable form (Not a picture)?
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.
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;
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.