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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 5 replies
  • 1051 views
  • 0 likes
  • 4 in conversation