data ecg ;
set renibus20(in=a)
renibus211(in=b1 where=(assess^=''))
renibus212(in=b2 where=(assess^=''))
renibus221(in=c1 where=(assess^=''))
renibus222(in=c2 where=(assess^=''))
renibus231(in=d1 where=(assess^=''))
renibus232(in=d2 where=(assess^='')) ;
subject=put(input(subject_id,best.),z3.) ;
length VISIT $20 ;
if a then VISIT='Screening' ;
if b1 or c1 or d1 then visit='Day 1 Predose' ;
if b2 or c2 or d2 then visit='Day 1 Predose' ;
VISITN=1.1*(b1 or c1 or d1)+1.2*(b2 or c2 or d2) ;
drop _name_ _label_ subject_id ;
run ;
I am getting error as
In one of your data sets in the SET statement, variable ASSESS is numeric; in another of your data sets variable ASSESS is character. You need to fix this in order to get this to work. ASSESS must always be numeric in each of your data sets; or it must always be character in each of your data sets.
In one of your data sets in the SET statement, variable ASSESS is numeric; in another of your data sets variable ASSESS is character. You need to fix this in order to get this to work. ASSESS must always be numeric in each of your data sets; or it must always be character in each of your data sets.
You need to go back to the start of your process, where the data is read into your SAS environment in the first place. Do not use proc import for this, instead use the same data step to read all files, then the datasets will have the same structure.
@TANMOY05 wrote:
In those datasets where variable ASSESS is character , is there anyway i present it as numeric as those variable contains no observations and therefore SAS is reading it as character and those variables too are needed to create dataset ecg.
In a data step, you rename ASSESS to something else (let's say ASSESS_C) and then create a new variable named ASSESS which is numeric and contains the numeric portion of whatever values are in ASSESS_C.
And also ... what @Kurt_Bremser said is good advice.
@TANMOY05 wrote:
data ecg ; set renibus20(in=a) renibus211(in=b1 where=(assess^='')) renibus212(in=b2 where=(assess^='')) renibus221(in=c1 where=(assess^='')) renibus222(in=c2 where=(assess^='')) renibus231(in=d1 where=(assess^='')) renibus232(in=d2 where=(assess^='')) ; subject=put(input(subject_id,best.),z3.) ; length VISIT $20 ; if a then VISIT='Screening' ; if b1 or c1 or d1 then visit='Day 1 Predose' ; if b2 or c2 or d2 then visit='Day 1 Predose' ; VISITN=1.1*(b1 or c1 or d1)+1.2*(b2 or c2 or d2) ; drop _name_ _label_ subject_id ; run ;
I am getting error as
ERROR: WHERE clause operator requires compatible variables.ERROR: Variable ASSESS has been defined as both character and numeric.what to do?even where=(not missing(assess)) is showing error Variable ASSESS has been defined as both character and numeric.
One suspects there is a LOGIC error on this line:
if b2 or c2 or d2 then visit='Day 1 Predose' ;
That perhaps the visit value should either have a different Day or something besides "Predose". Otherwise why have a different "If' to differentiate between b1 c1 and d1.
You may want to consider whether visit should be formed that way. You are actually containing two pieces of informat, Day and Dose status. Which may make it much harder to look at "Predose" vs other Dose status values.
Another consideration if you have many of these, such that you get up to values like 'Day 10 Dose' then your sort order for visit for many purposes will be "Day 1 ", "Day 10", "Day 11" , "Day 2" or similar. So you might be better off with a numeric Day value that sorts appropriately.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.