Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Programming
- /
- Macro Error? --- All variables in array list must be the same type?

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

☑ This topic is **solved**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 03-21-2023 01:26 PM
(1388 views)

```
%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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

11 REPLIES 11

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hello,

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

"

Hands-on-Workshop: "

"

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

SAS Documentation

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

"

Hands-on-Workshop: "

"

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

SAS Documentation

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

"

Hands-on-Workshop: "

"

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

SAS Documentation

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

"

Hands-on-Workshop: "

"

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

SAS Documentation

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Does the same thing with A<=B<=C

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

"

Hands-on-Workshop: "

"

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

SAS Documentation

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

"

Hands-on-Workshop: "

"

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

SAS Documentation

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. **Registration is now open through August 30th**. Visit the SAS Hackathon homepage.

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.