BookmarkSubscribeRSS Feed
gmuersch
Fluorite | Level 6

Hey everyone, 

 

I have a table, TEST, and I want to update the TEST.status =  "submitted" if TEST.ID exists in another table I have of IDs

 

I wrote this code below in proc sql but for some reason the IN keyword wont highlight and I am not getting the expected result

 

proc sql;

 

update work.test
set status = "submitted"
where id in
    (select ID from work.list_of_IDs);

quit;

 

It runs without errors but I get the note that no rows have been updated.

 

If anyone knows what is going wrong or can offer a solution I would really appreciate it, I have been struggling with this for some time now. 

6 REPLIES 6
Tom
Super User Tom
Super User

"highlight"?  Are you talking about something the editor is doing to give you a little help it finding typos?  I wouldn't worry about whether the editor knows how to highlight your code or not.

 

Test whether there are in fact any observations that need updating.

proc sql;
select count(*) as number_to_update 
from work.test
where id in (select ID from work.list_of_IDs)
;
quit;

Perhaps none of the values of ID in LIST_OF_IDS match the values of ID in TEST.

gmuersch
Fluorite | Level 6

Yeah I actually realized my list_of_IDs was incorrect, some leading zeros were truncated in excel and that was causing the issue. Thanks for the help!!

Tom
Super User Tom
Super User

@gmuersch wrote:

Yeah I actually realized my list_of_IDs was incorrect, some leading zeros were truncated in excel and that was causing the issue. Thanks for the help!!


Excel is where data goes to die.  Or at least get managled into unrecognizable junk.

Reeza
Super User

Do you have an Excel file or a CSV file?


@gmuersch wrote:

Yeah I actually realized my list_of_IDs was incorrect, some leading zeros were truncated in excel and that was causing the issue. Thanks for the help!!


 

PGStats
Opal | Level 21

It should work. Make sure the IDs are exactly the same in both tables. Watch for leading spaces or zeros if the IDs are character, or fields that differ but look the same only because of formats.

PG
ballardw
Super User

"IN" used that way is an operator and basically none of the operators like: + * - / OR AND NOT > < are highlighted. So that isn't to be worried about at all. Depending on SAS modules you'll find many key elements that are not highlighted and sometimes ones reported as "unknown keywords" just because the Editor hasn't been told to see them yet.

 

Small example data of your values may provide some insight. Only provide examples of the variables used.

Ready to join fellow brilliant minds for the SAS Hackathon?

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

Register today!
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.

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
  • 1020 views
  • 5 likes
  • 5 in conversation