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?
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.
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.
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)
;
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 -
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.
Thanks, everyone for guiding me!!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.