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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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