BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
hellohere
Pyrite | Level 9

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, 

 

sc.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
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;

Ksharp_0-1769068243026.png

 

Ksharp_1-1769068257156.png

 

View solution in original post

4 REPLIES 4
hellohere
Pyrite | Level 9

Transpose is fine if too tough to do so.

Ksharp
Super User
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;

Ksharp_0-1769068243026.png

 

Ksharp_1-1769068257156.png

 

PaigeMiller
Diamond | Level 26

@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, 

 

sc.jpg


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

--
Paige Miller
hellohere
Pyrite | Level 9

Thanks for your suggestion. The columns are gotten from SQL once for all. I know how to transpose, just feel 

something can be better. 

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
  • 4 replies
  • 136 views
  • 0 likes
  • 3 in conversation