Help using Base SAS procedures

Turn two columns into one

Reply
Occasional Contributor
Posts: 6

Turn two columns into one

Hi

I want to do some sort of append - I have something like this:

var 1 var2var3123
vvvvvvabc
zzzzzzefg

And I want:

var1var2var3l
vvvvvva
vvvvvvb
vvvvvvc
zzzzzzd
zzzzzze
zzzzzzf

How can I do this?

Thank you in advance!

Super User
Posts: 5,429

Re: Turn two columns into one

proc transpose or a data step using explicit output statment.

Data never sleeps
Super Contributor
Posts: 340

Re: Turn two columns into one

An array could work as well (there is no "d" in your original data):


Data Have;
  Input Var1 $ Var2 $ Var3 $ x_1 $ x_2 $ x_3 $;
  Datalines;
zz zz zz e f g
vv vv vv a b c
;
Run;

Data Want (Drop=x_Smiley Happy;
  Set Have;
  Array A $ x_:;
  Do over A;
    L=A;
Output;
  End;
Run;

Proc Print Data=Want Noobs; Run;

Ask a Question
Discussion stats
  • 2 replies
  • 210 views
  • 0 likes
  • 3 in conversation