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

This dataset was imported from an excel file.

raw SAS dataset as the follows:

ID    v1   v2

12    2    3

.     3    4

.     8    9

41   2    3

.     3    4

.     8    9

.     3    4

.     8    9

14    2    3

.     3    4

.     8    9

data wanted:

ID    v1   v2

12    2    3

12    3    4

12    8    9

41    2    3

41    3    4

41    8    9

41    3    4

41    8    9

14    2    3

14    3    4

14    8    9

Any easier way to do this ? thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

One way:

data want;

   set have;

   retain new_id;

   if id ne . then new_id=id;

   drop id;

   rename new_id=id;

run;

Good luck.

View solution in original post

3 REPLIES 3
Astounding
PROC Star

One way:

data want;

   set have;

   retain new_id;

   if id ne . then new_id=id;

   drop id;

   rename new_id=id;

run;

Good luck.

Ken_oy
Fluorite | Level 6

Thanks Astounding. :smileylaugh:

data_null__
Jade | Level 19

This is basically an LOCF problem and if you have more that a couple of variables that need to be carried forward you might find this helpful.

data missid;
   input ID v1 v2;
   retain dummy 1;
  
cards;
12    2    3
.     3    4
.     8    9
41   2    3
.     3    4
.     8    9
.     3    4
.     8    9
14    2    3
.     3    4
.     8    9
;;;;
   run;
data fillid(drop=dummy);
   update missid(obs=0) missid;
   by dummy;
   output;
  
call missing(of v1-v2);
   run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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