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

data vitals ;
set RAW.renibus20(in=a) RAW.renibus211(in=b1 where=(diabp^='')) RAW.renibus212(in=b2 where=(diabp^='')) RAW.renibus213(in=b3 where=(diabp^=''))
RAW.renibus22(in=c) RAW.renibus23(in=d) RAW.renibus24(in=e) RAW.renibus25(in=f) RAW.renibus28(in=g) ;
subject=put(input(subject_id,best.),z3.) ;
if a then VISIT='Screening' ;
if b1 or b2 or b3 then visit='Day 1' ;
if c then visit='Day 2' ;
if d then visit='Day 3' ;
if e then visit='Day 4' ;
if f then visit='Day 5' ;
if g then visit='Day 8' ;
VISITN=(b1 or b2 or b3)+(c)*2+(d)*3+(e)*4+(f)*5+(g)*8 ;
drop _name_ _label_ subject_id ;
run ;

 

error :where clause operator requires compatible variable

 

this is my code where the dataset raw.renibus211 ,raw.renibus212 and raw.renibus213 contains one of the  variables(column name) as DIABP, so why i am getting the error   where clause operator requires compatible variable?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Each open parenthesis needs a closing one.  Not closing the() around the dataset options after renibus211 you are confusing SAS.

 

Note the real fix is probably to simplify the whole process.  What is the overall goal here. Why are you using PROC IMPORT to read a simple CSV file?  If you just read it with a data step then there is no need to rename the variables or any confusion about whether DIABP is a numeric or character variable.

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26
where=(diabp^='')

This only works if the variable DIABP is character, it will not work if it it is numeric. One or more of the variables (not necessary DIABP) in the where clauses is not character, it is numeric.

 

You can probably fix the problem by changing the WHERE clauses to

 

where=(not missing(diabp))

which works properly on both numeric and character variables.

--
Paige Miller
TANMOY05
Obsidian | Level 7
Thanks for the help, But now i am getting error as multiple where
statements cannot be applied to same input data set as i am applying the
where statements on three datasets and inputting those three datasets to
create a new one.

Error: multiple where statements cannot be applied to same input data set


Tom
Super User Tom
Super User

You probably just messed up the parentheses.  Post your code using the Insert SAS Code (looks like the SAS running man icon) pop-up window.  It will help if you indent your code so you can more easily see what the list of datasets are and what options are being applied to each.

set
 RAW.renibus20(in=a)
 RAW.renibus211(in=b1 where=(not missing(diabp)))
 RAW.renibus212(in=b2 where=(not missing(diabp)))
 RAW.renibus213(in=b3 where=(not missing(diabp)))
 RAW.renibus22(in=c)
 RAW.renibus23(in=d)
 RAW.renibus24(in=e)
 RAW.renibus25(in=f)
 RAW.renibus28(in=g) 
;
TANMOY05
Obsidian | Level 7
proc import datafile = '/folders/myfolders/cliniops/excel data files/programs/subset1.csv'
out = raw.subset1
dbms = csv
replace;
run;

data raw.renibus20;
set RAW.subset1;
rename Subject_id= SUBJECT_ID
DIAST_VITALS1__ALSUBJSCN__ScrVst= DIABP
PU__VITALS1__ALSUBJSCN__ScrVst= HR
SYST_VITALS1__ALSUBJSCN__ScrVst= SYSBP
TEM_VITALS1__ALSUBJSCN__ScrVst= TEMP;
run;

data raw.renibus211;
set RAW.subset1;
rename Subject_id= SUBJECT_ID
DIAST_PREDOSV__COH1__Study_Day_1= DIABP
PU__PREDOSV__COH1__Study_Day_1= HR
SYST_PREDOSV__COH1__Study_Day_1= SYSBP
TEM_PREDOSV__COH1__Study_Day_1= TEMP;
run;

data raw.renibus212;
set RAW.subset1;
rename Subject_id= SUBJECT_ID
DIAST_PREDOSV__COH2__Study_Day_1= DIABP
PU__PREDOSV__COH2__Study_Day_1= HR
SYST_PREDOSV__COH2__Study_Day_1= SYSBP
TEM_PREDOSV__COH2__Study_Day_1= TEMP;
run;

data raw.renibus213;
set RAW.subset1;
rename Subject_id= SUBJECT_ID
DIAST_PREDOSV__COH3__Study_Day_1= DIABP
PU__PREDOSV__COH3__Study_Day_1= HR
SYST_PREDOSV__COH3__Study_Day_1= SYSBP
TEM_PREDOSV__COH3__Study_Day_1= TEMP;
run;

data raw.renibus22;
set RAW.subset1;
rename Subject_id= SUBJECT_ID
DIAST_PV__SD2__Study_Day_2= DIABP
PU__PV__SD2__Study_Day_2= HR
SYST_PV__SD2__Study_Day_2= SYSBP
TEM_PV__SD2__Study_Day_2= TEMP;
run;

data raw.renibus23;
set RAW.subset1;
rename Subject_id= SUBJECT_ID
DIAST_VITALS__SD3__Study_Day_3= DIABP
PU__VITALS__SD3__Study_Day_3= HR
SYST_VITALS__SD3__Study_Day_3= SYSBP
TEM_VITALS__SD3__Study_Day_3= TEMP;
RUN;

data raw.renibus24;
set raw. subset1;
rename Subject_id= SUBJECT_ID
DIAST_VITALS__SD4__Study_Day_4= DIABP
PU__VITALS__SD4__Study_Day_4= HR
SYST_VITALS__SD4__Study_Day_4= SYSBP
TEM_VITALS__SD4__Study_Day_4= TEMP;
run;

data raw.renibus25;
set RAW.subset1;
rename Subject_id= SUBJECT_ID
DIAST_VITALS__SD5__Study_Day_5= DIABP
PU__VITALS__SD5__Study_Day_5= HR
SYST_VITALS__SD5__Study_Day_5= SYSBP
TEM_VITALS__SD5__Study_Day_5= TEMP;
run;

data raw.renibus28;
set RAW.subset1;
rename Subject_id= SUBJECT_ID
DIAST_VITALS__SCM__Study_Day_8= DIABP
PU__VITALS__SCM__Study_Day_8= HR
SYST_VITALS__SCM__Study_Day_8= SYSBP
TEM_VITALS__SCM__Study_Day_8= TEMP;
run;

data vitals ;
	set 
	RAW.renibus20(in=a) 
	RAW.renibus211(in=b1 where=(not missing(diabp)) 
	RAW.renibus212(in=b2 where=(not missing(diabp)) 
	RAW.renibus213(in=b3 where=(not missing(diabp)) 
        RAW.renibus22(in=c) 
        RAW.renibus23(in=d) 
        RAW.renibus24(in=e) 
        RAW.renibus25(in=f) 
        RAW.renibus28(in=g) ;
	subject=put(input(subject_id,best.),z3.) ;
	if a then VISIT='Screening' ;
	if b1 or b2 or b3 then visit='Day 1' ;
	if c then visit='Day 2' ;
	if d then visit='Day 3' ;
	if e then visit='Day 4' ;
	if f then visit='Day 5' ;
	if g then visit='Day 8' ;
	VISITN=(b1 or b2 or b3)+(c)*2+(d)*3+(e)*4+(f)*5+(g)*8 ;
	drop _name_ _label_ subject_id ;
run ;

I am getting these in the log file -

 

 
72
73 data vitals ;
74 set
75 RAW.renibus20(in=a)
76 RAW.renibus211(in=b1 where=(not missing(diabp))
77 RAW.renibus212(in=b2 where=(not missing(diabp))
______________
22
ERROR: Multiple WHERE statements cannot be applied to the same input data set.
ERROR 22-7: Invalid option name RAW.RENIBUS212.
 
78 RAW.renibus213(in=b3 where=(not missing(diabp))
79 RAW.renibus22(in=c)
_____________
22
ERROR 22-7: Invalid option name RAW.RENIBUS22.
 
80 RAW.renibus23(in=d)
81 RAW.renibus24(in=e)
82 RAW.renibus25(in=f)
83 RAW.renibus28(in=g) ;
84 subject=put(input(subject_id,best.),z3.) ;
85 if a then VISIT='Screening' ;
86 if b1 or b2 or b3 then visit='Day 1' ;
87 if c then visit='Day 2' ;
88 if d then visit='Day 3' ;
89 if e then visit='Day 4' ;
90 if f then visit='Day 5' ;
91 if g then visit='Day 8' ;
92 VISITN=(b1 or b2 or b3)+(c)*2+(d)*3+(e)*4+(f)*5+(g)*8 ;
93 drop _name_ _label_ subject_id ;
94 run ;
 
look at the errors, how do I solve it??
 
 
 

 

Tom
Super User Tom
Super User

Each open parenthesis needs a closing one.  Not closing the() around the dataset options after renibus211 you are confusing SAS.

 

Note the real fix is probably to simplify the whole process.  What is the overall goal here. Why are you using PROC IMPORT to read a simple CSV file?  If you just read it with a data step then there is no need to rename the variables or any confusion about whether DIABP is a numeric or character variable.

TANMOY05
Obsidian | Level 7

Thanks, everyone for guiding me!!

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 2191 views
  • 1 like
  • 3 in conversation