BookmarkSubscribeRSS Feed
cody_q
Calcite | Level 5

Hey all ,

I am working data set with a lot of columns more than 50 .
I would like to append all the content of the 50 columns into a column with many rows.

I have to use SAS EG to do it .

Anybody knows how to?

Thanks .

Cody

5 REPLIES 5
Alpay
Fluorite | Level 6

Can you provide some example data and the way you want to append the data?

Example:

Have:

Want:

ChrisHemedinger
Community Manager

EG offers Data->Transpose (general) and Data->Stack Columns (specific for your case), but it's still a bit tricky to manage without a "recipe".  I find Rick Wicklin's blog posts on transposing to be very helpful.  Here's one about converting from wide to long.

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
cody_q
Calcite | Level 5

Hi all ,


Thank you for your replies. Here's the "recipe". I hope it makes sense to you all.

F1 to F10 are the columns.

 

F1


 

 

F2


 

 

F3


 

 

F4


 

 

F5


 

 

F6


 

 

F7


 

 

F8


 

 

F9


 

 

F10


 

 

There


 

 

are


 

 

40


 

 

students


 

 

in


 

 

the


 

 

class


 

 

.


 

 

They


 

 

are


 

 

all


 

 

studying


 

 

for


 

 

Math


 

 

and


 

 

Science


 

 

.


 

 

They


 

 

have


 

 

learnt


 

 

valuable


 

 

lessons


 

 

from


 

 

the


 

 
  1. Classes.
 

 

The


 

 

teachers


 

 

are


 

 

proud


 

 

of


 

 

them


 

 

.


 

 


 

 


 

 


 

 


 

 


 

 


 

 


 

 


 

Become to F1 as the only column with many rows.

 

F1


 

 

There


 

 

are


 

 

40


 

 

students


 

 

in


 

 

the


 

 

class


 

 

.


 

 

They


 

 

are


 

 

all


 

 

studying


 

 

for


 

 

Math


 

 

and


 

 
  1. Science.
 

 

They


 

 

have


 

 

learnt


 

 

valuable


 

 

lessons


 

 

from


 

 

the


 

 
  1. classes.
 

 

The


 

 

teachers


 

 

are


 

 

proud


 

 

of


 

 

them


 

 

.


 

Thank you.

Linlin
Lapis Lazuli | Level 10

how about:

data have;

input (a1-a5) ($);

cards;

a b c d e f

g h i j k l

;

data want;

   set have;

   array _a(*) $ a1-a5;

   do _n_=1 to dim(_a);

   f1=_a(_n_);

   output;

   end;

   keep f1;

proc print;run;

Linlin

QLi
Fluorite | Level 6 QLi
Fluorite | Level 6

Try to use proc transpose and maybe work it out.

data have;

input Name $ Sex $ Age height weight;

cards;

alfred m 14 69 112.5

alice f 13 56.5 84

barbara f 13 65.3 98

;

run;

proc sort data=have out=have2; by name; run;

proc transpose data=have2 out=have_t;

by name;

var height weight age ; 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
  • 5 replies
  • 2173 views
  • 0 likes
  • 5 in conversation