How to make each value a variable in SAS?

Accepted Solution Solved
Reply
Contributor
Posts: 32
Accepted Solution

How to make each value a variable in SAS?

I have hundreds of value in the following format in one SAS dataset:

ID                  Chemical     Value

AS4001X    abc               1.4

AS4001X   def                3.2

AS4001X    ghi                3.4

BC4002Y    abc               2.1

BC4002Y    def                4.3

BC4002Y    ghi               5.4

..................

and so on

I would like is to change each value of 'Chemical' into a variable so that I get the new dataset that look like this:

ID                abc         def         ghi

AS4001X    1.4           3.2       3.4

BC4002Y    2.1           4.3       5.4

...........

Please suggest how do I go about about making such modification of dataset. I thank you all in advance.

Sapkota


Accepted Solutions
Solution
‎06-11-2014 12:22 PM
Respected Advisor
Posts: 4,649

Re: How to make each value a variable in SAS?

Typical task for Proc Transpose:

proc transpose data=have out=want(drop=_name_);

by ID;

var Value;

id Chemical;

run;

PG

PG

View solution in original post


All Replies
Super User
Posts: 17,829

Re: How to make each value a variable in SAS?

Look into Proc Transpose

Solution
‎06-11-2014 12:22 PM
Respected Advisor
Posts: 4,649

Re: How to make each value a variable in SAS?

Typical task for Proc Transpose:

proc transpose data=have out=want(drop=_name_);

by ID;

var Value;

id Chemical;

run;

PG

PG
☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 176 views
  • 5 likes
  • 3 in conversation