DATA Step, Macro, Functions and more

data manipulation question!

Reply
Regular Contributor
Posts: 152

data manipulation question!

Hello experts,

How do I convert table A to table B like following:

Table A:

variable1

a               

aaa           

bbb

ccc

ddd

eee

b

eee

ggg

hhh

jjj

qqq

...

...

Table B

variable1      variable2            

aaa               a

bbb               a

ccc                a

ddd               a

eee               a

eee               b

ggg               b

hhh               b

jjj                   b

qqq                b

...

...

Thanks so much!

Super User
Posts: 7,832

Re: data manipulation question!

data want;

set have;

retain variable2;

if length(variable1) = 1

then do;

  variable2 = variable1;

  delete;

end;

run;

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 1 reply
  • 168 views
  • 0 likes
  • 2 in conversation