BookmarkSubscribeRSS Feed
Dhana18
Obsidian | Level 7

OR does not work I need both conditions patient id and visit date. Thank you.

novinosrin
Tourmaline | Level 20

The idea of OR was to see if there are records actually present in your data

Reeza
Super User

@Dhana18 wrote:

I used this datastep

DATA SUBMTWO.Clinicdata29_1;

SET SUBMTWO.Clinicdata29;

IF CL_PATIENTID='50055' then flag1=1;

if visdate='11/27/2017' then flag2=1;

RUN;

then used this proc print statement, and this is the output

 

Obs VISDATE CL_PATIENTID83910851203
2017/10/17 50055
2017/11/27 50055
2017/12/11 50055

 

 


Show the full log (including the proc print) and include the flags in the PROC PRINT. Without them, you can't see where the issue is coming from. 

Dhana18
Obsidian | Level 7

DATA SUBMTWO.Clinicdata29_1;

SET SUBMTWO.Clinicdata29;

IF CL_PATIENTID='50055' then flag1=1;

if visdate='11/27/2017' then flag2=1;

RUN;

 

 

12 DATA SUBMTWO.Clinicdata29_1;

13 SET SUBMTWO.Clinicdata29;

14 IF CL_PATIENTID='50055' then flag1=1;

15 if visdate='11/27/2017' then flag2=1;

16 RUN;

NOTE: There were 3414 observations read from the data set SUBMTWO.CLINICDATA29.

NOTE: The data set SUBMTWO.CLINICDATA29_1 has 3414 observations and 59 variables.

NOTE: DATA statement used (Total process time):

real time 0.10 seconds

cpu time 0.00 seconds

proc print data=SUBMTWO.Clinicdata29_1 ;

var flag1 flag2 CL_patientid toc_vis;

where cl_patientid="50055";

run;

 

25 proc print data=SUBMTWO.Clinicdata29_1 ;

26 var flag1 flag2 CL_patientid toc_vis;

27 where cl_patientid="50055";

28 run;

NOTE: There were 3 observations read from the data set SUBMTWO.CLINICDATA29_1.

WHERE cl_patientid='50055';

NOTE: PROCEDURE PRINT used (Total process time):

real time 0.03 seconds

cpu time 0.01 seconds

Reeza
Super User
Can you show the PROC PRINT results please as well?
ballardw
Super User

@Dhana18 wrote:

I used this datastep

DATA SUBMTWO.Clinicdata29_1;

SET SUBMTWO.Clinicdata29;

IF CL_PATIENTID='50055' then flag1=1;

if visdate='11/27/2017' then flag2=1;

RUN;

then used this proc print statement, and this is the output

 

Obs VISDATE CL_PATIENTID83910851203
2017/10/17 50055
2017/11/27 50055
2017/12/11 50055

 

 


Which shows no value of 11/27/2017 for the VISDATE variable. If that is character variable then you want to specify '2017/11/27' if you want to set that variable for the middle row.

Dhana18
Obsidian | Level 7

Thank you for your persistent support.

I used this

DATA SUBMTWO.Clinicdata29_1;

SET SUBMTWO.Clinicdata29;

if VISDATE='2017/11/27' AND CL_PATIENTID='50055' then TOC_VIS="1";

RUN;

and worked. yay! I needed to put the date "201/11/27".

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