DATA Step, Macro, Functions and more

A typical data step problem

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

A typical data step problem

Hi all,

I have a SAS data set like below:

MoisorgNaCaMg
00.87751.6471.008451.10295
1000.711451.370250.762750.8316
2000.625051.205550.68580.7398
3300.55891.075950.627750.6885


And I want a new data set to be like this...

Mois_retTrtResponse
0org0.8775
0Na1.647
0Ca1.00845
0Mg1.10295
100org0.71145
100Na1.37025
100Ca0.76275
100Mg0.8316
200org0.62505
200Na1.20555
200Ca0.6858
200Mg0.7398
330org0.5589
330Na1.07595
330Ca0.62775
330Mg0.6885


Please tell me the solution.

With Best Regards,

Manoj Khandelwal


Accepted Solutions
Solution
‎07-02-2011 04:24 AM
Contributor
Posts: 36

A typical data step problem

Simple solution is to use PROC TRANSPOSE

proc transpose data=chem out=chem2;

  var org na ca mg;

  by mois;

run;

Default column names will be mois, _NAME_ and COL1

View solution in original post


All Replies
Solution
‎07-02-2011 04:24 AM
Contributor
Posts: 36

A typical data step problem

Simple solution is to use PROC TRANSPOSE

proc transpose data=chem out=chem2;

  var org na ca mg;

  by mois;

run;

Default column names will be mois, _NAME_ and COL1

Occasional Contributor
Posts: 19

A typical data step problem

Thanks barheat. It works.

Respected Advisor
Posts: 3,777

A typical data step problem

Default column names will be mois, _NAME_ and COL1

Use NAME= option and RENAME data set option'

proc transpose name=trt   out=chem2(rename=(col1=response))

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 141 views
  • 0 likes
  • 3 in conversation