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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.