DATA Step, Macro, Functions and more

creating vertical data structure

Accepted Solution Solved
Reply
Super Contributor
Posts: 271
Accepted Solution

creating vertical data structure

[ Edited ]

Hello,

 

I have a data structure like this.

 

id time test_1 test_2

1   1     4       8

1   2     5       6

1   3     4       7

2   1     5       8

2   2     4       5

 

I want like this.

id time test     value

1  1    test_1    4

1  1    test_2    8

1  2    test_1    5

1  2    test_2    6

1  3    test_1    4

1  3    test_2    7

2  1    test_1    5

2  1    test_2    8

2  2    test_1    4

2  2    test_2    5

 

thanks for your help.


Accepted Solutions
Solution
‎02-28-2017 08:48 PM
Super User
Super User
Posts: 7,955

Re: creating vertical data structure

Posted in reply to SAS_inquisitive

Post test data in the form of a datastep.  As such this is just an example:

proc transpose data=have out=want;
  by id time;
  var test_:;
run;

View solution in original post


All Replies
Super User
Posts: 19,792
Solution
‎02-28-2017 08:48 PM
Super User
Super User
Posts: 7,955

Re: creating vertical data structure

Posted in reply to SAS_inquisitive

Post test data in the form of a datastep.  As such this is just an example:

proc transpose data=have out=want;
  by id time;
  var test_:;
run;
Super User
Posts: 7,782

Re: creating vertical data structure

Posted in reply to SAS_inquisitive

Use proc transpose.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 130 views
  • 4 likes
  • 4 in conversation