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

if Visitn=999, then need to change it to scheduled.
EX: If the previous Visit is 7, and if the next visit is Unschedule then AVISITN=7.1,
if the same vist has more than one unschedule, then seq schould come as 7.1,7.2..

 

 haow can i change

 

 

eg; 1

       2

       3

      4

      5

      999

      6

after 5 i want 5.1, 5.2 how can i get plz help....

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

@Aswanth

If you want answers providing code then you need to provide representative sample data (as a fully working SAS data step creating such sample data) and then clearly show the desired result.

View solution in original post

5 REPLIES 5
Astounding
PROC Star

I'm going to assume you have more variables in your data set ... at least a patient identifier so you know which visit belongs to which patient.

 

What should happen if the first visit is 999 for a patient?  Well, I will assume you want AVISITN to be 0.1, 0.2, etc.

 

proc sort data=have;

by patient visitn;

run;

 

data want;

set have;

by patient;

if first.patient then avisitn=0;

if visit=999 then avisitn + 0.1;

else avisitn = visitn;

run;

 

********** EDITED:

 

Upon further reflection, the sort should be by PATIENT only:

 

proc sort data=have;

by patient;

run;

 

Otherwise, it put's all the patient's 999 visits at the end, which is the wrong order.  If you have a variable that would put the in the proper order, you can use that as well:

 

proc sort data=have;

by patient date;

run;

Aswanth
Calcite | Level 5
thank you so much
Aswanth
Calcite | Level 5
but its not worked for me
SAS_inquisitive
Lapis Lazuli | Level 10

Please see the first example code in this article (https://www.mwsug.org/proceedings/2009/stats/MWSUG-2009-D14.pdf).

Patrick
Opal | Level 21

@Aswanth

If you want answers providing code then you need to provide representative sample data (as a fully working SAS data step creating such sample data) and then clearly show the desired result.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1999 views
  • 0 likes
  • 4 in conversation