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

RETAIN MISSING VALUE OF VISITNUM WITH PREVIOUS VALUE WITH ADDITION OF 0.01

 

EX;

VISTNUM

1

.

.

2

.

3

THEN I WANT

VISTNUM

1

1.01

1.02

2

2.01

3

 

 

 

WhatsApp Image 2018-03-28 at 7.01.21 PM.jpeg

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Make a new variable. You can always rename it if you want.

data want ;
 set have ;
 if missing(visitnum) then newvar+0.01 ;
 else newvar=visitnum;
run;
Obs    visitnum    newvar

 1         1        1.00
 2         .        1.01
 3         .        1.02
 4         2        2.00
 5         .        2.01
 6         3        3.00

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Make a new variable. You can always rename it if you want.

data want ;
 set have ;
 if missing(visitnum) then newvar+0.01 ;
 else newvar=visitnum;
run;
Obs    visitnum    newvar

 1         1        1.00
 2         .        1.01
 3         .        1.02
 4         2        2.00
 5         .        2.01
 6         3        3.00
rvsidhu035
Quartz | Level 8
data given;
infile datalines dlm=' ' missover dsd;
input subject visit $11. visitnum 16-18;
datalines;
100 Screening 	-1
100 day 1 		 1
100 day 2 		 2
100 UNSCHEDULED 
100 UNSCHEDULED
100 day 3 		 3
100 day 4 		 4
100 UNSCHEDULED 
100 day 5	 	 5
100 UNSCHEDULED   
100 UNSCHEDULED  
100 UNSCHEDULED   
;
run;
data output1(rename=(nvar=visitnum));
length subject 3.;
length visit $20.;
set given;
if visitnum ge 1 or nmiss(visitnum) eq 1 then do;
if nmiss(visitnum) eq 1 then do; nvar+0.01;visit=catx(':',visit,put(nvar,4.2));end;
else  nvar=visitnum;visit=visit;end;
else nvar=visitnum;
drop visitnum;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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