I have data below. Dataset also attached.
How to line plot all the info into one Picture, without Proc Transpose?!
Ten lines: one row for each
y=the value of off_max_ct_xx:
x=100/80/60/40/30/20/10/5 at the column names[off_max_ct_xx]
Thanks,
libname x v9 'C:\Users\xiakeshan\Documents\Downloads';
data x;
set x._t_mm_temp_coll_n;
array _x{*} off_max_ct_: ;
do i=1 to dim(_x);
y=_x{i};
x=input(scan(vname(_x{i}),-1,'_'),best.);
output;
end;
keep x y xahead;
run;
proc sgplot data=x;
series x=x y=y /group=xahead ;
run;
Transpose is fine if too tough to do so.
libname x v9 'C:\Users\xiakeshan\Documents\Downloads';
data x;
set x._t_mm_temp_coll_n;
array _x{*} off_max_ct_: ;
do i=1 to dim(_x);
y=_x{i};
x=input(scan(vname(_x{i}),-1,'_'),best.);
output;
end;
keep x y xahead;
run;
proc sgplot data=x;
series x=x y=y /group=xahead ;
run;
@hellohere wrote:
I have data below. Dataset also attached.
How to line plot all the info into one Picture, without Proc Transpose?!
Ten lines: one row for each
y=the value of off_max_ct_xx:
x=100/80/60/40/30/20/10/5 at the column names[off_max_ct_xx]
Thanks,
Best practice is to NOT arrange the data like this in the first place. Specifically, you have incorporated some meaningful data that the plot needs in the variable name — in this case, specifically, the data in the variable name is the _100 and _80 and so on. Data belongs in variable values, not in the variable name.
So a better arrangement would be to have the 100 and 80 and so on in their own variable, perhaps named VALUE, which contains the numeric values 100 and 80 and so on. This is called a long data set, and is always preferable to storing data in variable names. Why? Because most SAS procedures are designed to work on long data sets. In your case, the graph you want can ONLY be created from a long data set, so a transpose is required, and @Ksharp has provided a transpose for you, even if it is not PROC TRANSPOSE.
See Maxim 19.
Thanks for your suggestion. The columns are gotten from SQL once for all. I know how to transpose, just feel
something can be better.
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.