BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AKHILA
Obsidian | Level 7

hi,

I have a dataset like this;

ID             A              B          C       D

1              21          45          90     76

1              25          32          78      21

2             34           74           34     89

2             43            88          12      94

2             54            33          77      90

I want to do transposing and the desired o/p will be like

ID        _name_     value

1              A             21

1              B             45

1              C             90

1              D             76

1              A              25

1              B              32

1              C              78

1              D              21

2              A              34

2              B              74

2              C              34

2              D              89

...............and so on...

how can i do this?

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data have;
input ID A B C D;
datalines;
1 21 45 90 76
1 25 32 78 21
2 34 74 34 89
2 43 88 12 94
2 54 33 77 90
;

data want(keep= ID _name_ value);
   set have;
   array _{4} A B C D;
   do i=1 to dim(_);
      _name_=vname(_[i]);
      value=_[i];
      output;
   end;
run;

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20
data have;
input ID A B C D;
datalines;
1 21 45 90 76
1 25 32 78 21
2 34 74 34 89
2 43 88 12 94
2 54 33 77 90
;

data want(keep= ID _name_ value);
   set have;
   array _{4} A B C D;
   do i=1 to dim(_);
      _name_=vname(_[i]);
      value=_[i];
      output;
   end;
run;
AKHILA
Obsidian | Level 7

thank you somuch. it works

PeterClemmensen
Tourmaline | Level 20

Anytime, glad to help 🙂

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 517 views
  • 1 like
  • 2 in conversation