BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12
%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.
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@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.

View solution in original post

11 REPLIES 11
ybz12003
Rhodochrosite | Level 12

Hello,

It looks like I still have an unsolving error in the codes.

yabwon
Onyx | Level 15

You have a dot(".") in your code instead a comma(","), should be: 

if caseid in ('E1' , 'K8','R0','ER') then delete;

Bart 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Tom
Super User Tom
Super User

@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.

yabwon
Onyx | Level 15

True, SAS does not care 🙂 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

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

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



PaigeMiller
Diamond | Level 26

When macros don't run, its not necessarily a macro error. This is a base SAS error in your code, not a macro error.

--
Paige Miller
Tom
Super User Tom
Super User

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?

yabwon
Onyx | Level 15

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
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



sas-innovate-white.png

Missed SAS Innovate in Orlando?

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.

 

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 2759 views
  • 6 likes
  • 4 in conversation