BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bhca60
Quartz | Level 8
proc sql;
create table Btable
as select
    id,
    name,
    dob
FROM table1
UNION
SELECT 
    id,
	name,
	dob
FROM table2
where id IN ('12345' '123456');
quit;

I have tried everything to filter on these two ID's but i keep getting errors. I tried separating with a comma, semicolon - nothing seems to work.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Is ID a numeric variable or a character variable?  Does it have a format attached to it? Which format? Is it a SAS system format or a user defined format.  Remember you need to test for the actual values, not the values are displayed by the format.

 

Why are you filtering on just one of the two tables you are combining?

View solution in original post

6 REPLIES 6
SASKiwi
PROC Star

There is no obvious syntax error in your posted code. You need to post your complete SAS log including notes and errors so we can see what is happening.

ballardw
Super User

AS an absolute minimum include the actual text of any errors. Much better is to show the entire log for the procedure run with the code and all notes, warnings or errors associated with that procedure. Copy the text from the LOG, on the forum open a text box using the </> icon above the message window and paste the copied text.

 

Is it as simple as your ID variable is numeric and you are getting errors about the wrong type such as

ERROR: Expression using IN has components that are of different data types.

Then don't put quotes around the values.

bhca60
Quartz | Level 8
I've gotten that error before but I got this error for the above:
ERROR: Expression using IN has components that are of different data types.
NOTE: The IN referred to may have been transformed from an OR to an IN at some point during PROC SQL WHERE clause optimization.

Nothing seems to work - single quotes, double quotes, commas, no commas, semicolons...sometimes it just ignores the filter entirely and brings in all data. when i remove the quotes, it brings in all data.
Tom
Super User Tom
Super User

Is ID a numeric variable or a character variable?  Does it have a format attached to it? Which format? Is it a SAS system format or a user defined format.  Remember you need to test for the actual values, not the values are displayed by the format.

 

Why are you filtering on just one of the two tables you are combining?

bhca60
Quartz | Level 8
that was it! i didnt filter on both - thank you thank you!

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 796 views
  • 0 likes
  • 5 in conversation