BookmarkSubscribeRSS Feed
vem
Calcite | Level 5 vem
Calcite | Level 5

Hi Good day!

I am trying to stack 26 columns into one column in sas enterprise guide....and its ending up with the error "THE ID VALUE 'STACKEDVALUES' OCCURS TWICE IN THE INPUT DATA SET".I wanted the repeated values as present in the data base (don't want to elminate the duplicates).

Any help ....

for example :

mem_id  type_1  type_2

a001        x            a

a002        y            b

a003        z            c

and stack expecting like

mem_id name      type

a001     type_1    x

a001     type_2    a

a002     type_1    y

a002     type_2   b

a003     type_1   z

a003     type_1   c

2 REPLIES 2
ballardw
Super User

Please describe in considerable detail exactly how you are attempting to stack things. Code generated would be best.

You might also have to show some example of your current data and what you want it to look like afterwards.

 

Are you attempting to put multiple values into a single variable of one observation or create additional observations, one per variable?

Ksharp
Super User
It is easy for coding.



data have;
input (mem_id  type_1  type_2) ($);
cards;
a001        x            a
a002        y            b
a003        z            c
;
run;
data want;
 set have;
 array x{*} $ type_:;
 do i=1 to dim(x);
  name=vname(x{i});type=x{i};output;
 end;
 drop i type_:;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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