BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
newboy1218
Quartz | Level 8

Hi, I have a dataset like this:

 

obs  X

1      a

2

3

4      b

5

6

7

8      c

9

10

 

 

and I want to end up having this:

 

obs  X

1      a

2      a

3      a

4      b

5      b

6      b

7      b

8      c

9      c

10     c

 

How can I do this? I tried to loop through each row but it does not work.

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data have;
infile cards truncover;
input obs  X $;
cards;
1      a
2
3
4      b
5
6
7
8      c
9
10
;

data want;
set have;
retain t;
if not missing(x) then t=x;
else x=t;
drop t;
run;

View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20
data have;
infile cards truncover;
input obs  X $;
cards;
1      a
2
3
4      b
5
6
7
8      c
9
10
;

data want;
set have;
retain t;
if not missing(x) then t=x;
else x=t;
drop t;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1809 views
  • 0 likes
  • 2 in conversation