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

Hi there, 

 

 I am trying to pull in data from a REDCap database, but I only want data from one dataset to create a dashboard. Unfortunately, I keep having trouble. 

 

Here is my code so far:

Setting the library
***;
libname enroll "X:\SPH\Restricted\Winthrop\Current Projects\Biobank OCTRI\SAS";

data pulmcon (keep=id enrolldate birhdate sex hispanic race currentinsurance smoke height heightmeas currentweight currentweightmeas immuneany_enr copd bronch asthma cf othername inhaleenroll_enr pftdate1 fvcraw fvcdate1 fev1raw1 fev1date1 ratiodate1);
set redcap;
where newntm = 'pulmonary control';
run;

proc print;

 

The data I want is the pulmonary control data from newntm. 

What am I doing wrong? 

 

Thank you in advance. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
ERROR: WHERE clause operator requires compatible variables.

So variable newntm must be numeric, and you cannot compare its value to a character string.

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26
where newntm = 'pulmonary control';

 

The capitalization and spelling and spaces between the words must match exactly, or you won't get the right records.

 

By the way, you have not explained what you see that indicates you are getting the wrong results. Please tell us what you see that is wrong, and what you expect. That will help us get to the right answer quickly.

--
Paige Miller
grhyne
Calcite | Level 5
Sorry, here are the issues the log is telling me about:
18279 libname enroll "X:\SPH\Restricted\Winthrop\Current Projects\Biobank OCTRI\SAS";
NOTE: Libref ENROLL was successfully assigned as follows:
Engine: V9
Physical Name: X:\SPH\Restricted\Winthrop\Current Projects\Biobank OCTRI\SAS
18280

NOTE: No observations in data set WORK.PULMCON.
NOTE: PROCEDURE PRINT used (Total process time):
real time 4:09.05
cpu time 4.10 seconds


18281 data pulmcon (keep=id enrolldate birthdate sex hispanic race currentinsurance smoke height
18281! heightmeas currentweight currentweightmeas immuneany_enr copd bronch asthma cf othername
18281! inhaleenroll_enr pftdate1 fvcraw fvcdate1 fev1raw1 fev1date1 ratiodate1);
18282 set redcap;
18283 where newntm = 'pulmonary control';
ERROR: WHERE clause operator requires compatible variables.
18284 run;

WARNING: The variable enrolldate in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable birhdate in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable hispanic in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable race in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable othername in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable pftdate1 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable fvcraw in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.PULMCON may be incomplete. When this step was stopped there were 0
observations and 18 variables.
WARNING: Data set WORK.PULMCON was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

PaigeMiller
Diamond | Level 26
ERROR: WHERE clause operator requires compatible variables.

So variable newntm must be numeric, and you cannot compare its value to a character string.

--
Paige Miller

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!

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
  • 3 replies
  • 302 views
  • 0 likes
  • 2 in conversation