%let i=(&rr + 1);
%let rr=%eval(&i);
proc sql;
create table inpcr&rr as
select studysite,caseid,scrdate,inptadmitdt,inptdischargedt, intck('day',inptadmitdt, inptdischargedt) as c_los
from ds2INP
where scrdate ^=. and inptadmitdt ^=. and inptdischargedt ^=. and inptadmitdt ne '09SEP9999'd and inptdischargedt ne '09SEP9999'd
and (calculated c_los<0 or calculated c_los>100)
order by studysite,caseid;
%let inp_&rr.a=%str(Missing length of stay or extreme value [negative or >100 days]);
ods proclabel "Check &rr:&&&inp_&rr.a";
data inpcr&rr;
set inpcr&rr;
*if inptdischargedt='09SEP9999'd then delete;
var1="scrdate="||trim(left(put(scrdate,mmddyy10.)))
||', '||"inptadmitdt="||trim(left(put(inptadmitdt,mmddyy10.)))
||', '||"inptdischargedt="||trim(left(put(inptdischargedt,mmddyy10.)))
||', '||"c_los="||trim(left(put(c_los,3.)));
format studysite studysite.;
/* site confirmed with checks */
if caseid in ('E1'.'K8','R0','ER') then delete;
run;
%createINP;
MPRINT(ARIINPCHART): data inpcr26; MPRINT(ARIINPCHART): set inpcr26; MPRINT(ARIINPCHART): *if inptdischargedt='09SEP9999'd then delete; MPRINT(ARIINPCHART): var1="scrdate="||trim(left(put(scrdate,mmddyy10.))) ||', '||"inptadmitdt="||trim(left(put(inptadmitdt,mmddyy10.))) ||', '||"inptdischargedt="||trim(left(put(inptdischargedt,mmddyy10.))) ||', '||"c_los="||trim(left(put(c_los,3.))); MPRINT(ARIINPCHART): format studysite studysite.; ERROR: All variables in array list must be the same type, i.e., all numeric or character. MPRINT(ARIINPCHART): if caseid in ('EH1R09181'.'EK1R01948','EK2R05147','ER1R01720') then delete; MPRINT(ARIINPCHART): run; NOTE: The SAS System stopped processing this step because of errors.
@yabwon wrote:
And since it is a data step it should be:
if caseid in ('E1' 'K8' 'R0' 'ER') then delete;
Comma is separator in SQL, in data step it is space.
Bart
SAS does not care whether you use space or comma (or use both for that matter) as the delimiter in a list of value for the IN operator. Does not matter whether the code is plain SAS code or PROC SQL code.
Hello,
It looks like I still have an unsolving error in the codes.
You have a dot(".") in your code instead a comma(","), should be:
if caseid in ('E1' , 'K8','R0','ER') then delete;
Bart
And since it is a data step it should be:
if caseid in ('E1' 'K8' 'R0' 'ER') then delete;
Comma is separator in SQL, in data step it is space.
Bart
@yabwon wrote:
And since it is a data step it should be:
if caseid in ('E1' 'K8' 'R0' 'ER') then delete;
Comma is separator in SQL, in data step it is space.
Bart
SAS does not care whether you use space or comma (or use both for that matter) as the delimiter in a list of value for the IN operator. Does not matter whether the code is plain SAS code or PROC SQL code.
True, SAS does not care 🙂
Maybe doesn't care but pays attention 😄 😄 😄
1 data test1; 2 set test; 3 where X in ("A" "B" "C"); 4 run; NOTE: There were 1 observations read from the data set WORK.TEST. WHERE X in ('A', 'B', 'C'); NOTE: The data set WORK.TEST1 has 1 observations and 1 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.01 seconds 1 proc sql feedback; 2 create table test2 as 3 select * 4 from test 5 where X in ("A" "B" "C") 6 ; NOTE: Statement transforms to: select TEST.x from WORK.TEST where TEST.x in ('A', 'B', 'C'); NOTE: Table WORK.TEST2 created, with 1 rows and 1 columns. 7 quit; NOTE: PROCEDURE SQL used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
Does the same thing with A<=B<=C
My favourite is this one:
You can't use the maximum operator ("<>") in the WHERE clause because it is interpreted as "not equals" and SAS says:
1 data test;
2 x=1;y=0;output;
3 x=0;y=1;output;
4 x=1;y=1;output;
5 x=0;y=0;output;
6 run;
NOTE: The data set WORK.TEST has 4 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
7
8 data test1;
9 set test;
10 where X <> Y;
NOTE: The "<>" operator is interpreted as "not equals".
11 run;
NOTE: There were 2 observations read from the data set WORK.TEST.
WHERE X not = Y;
but... when you use "x max y" see what it writes:
12 13 data test2; 14 set test; 15 where X max Y; 16 run; NOTE: There were 3 observations read from the data set WORK.TEST. WHERE X<>Y;
😄 😄
Bart
When macros don't run, its not necessarily a macro error. This is a base SAS error in your code, not a macro error.
The error message does not seem to have anything to do with the code around it. There is no ARRAY statement there that I can see. Is perhaps the actual source of the error earlier in the code somewhere? Is SAS somehow not seeing the DATA statement as the start of a statement so the ARRAY statement it is talking about is actually earlier in the generated SAS code?
It is (as I wrote) the dot:
1 data test; 2 x="A"; 3 run; NOTE: The data set WORK.TEST has 1 observations and 1 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.01 seconds 4 5 data test1; 6 set test; 7 if X in ("A" . "B" , "C"); ERROR: All variables in array list must be the same type, i.e., all numeric or character. 8 run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.TEST1 may be incomplete. When this step was stopped there were 0 observations and 1 variables. WARNING: Data set WORK.TEST1 was not replaced because this step was stopped. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.
Ready to level-up your skills? Choose your own adventure.