BookmarkSubscribeRSS Feed
zhou_larry
Calcite | Level 5

I'm very new to SAS - switched jobs to a place that uses SAS enterprise - and have been doing readying a lot of SAS literature on forums and got some books already, but i can't seem to figure this out! Please help! essentially I need the equivalent of a Vlookup and all the syntax before and after the statement

I have Table_A (Table in SAS) and Table_B (external table in excel). Table_A has 150,000 rows, while Table_B has 10 rows. I'm trying to write an if-then clause that:

IF Table_A.column1 [has one of the variables in] Table_B.column1 THEN write 'TRUE' [in Table_B.column2]

After that, I would probably sort and take NOT MISSING from Table_B.column2 to cut the table down to a more manageable size.

Apologies if this is too simple, but I can't find anything that works! Any suggestions of what PROC or what not would greatly be appreciated. Thanks, Larry.

1 REPLY 1
Tom
Super User Tom
Super User

First step is to get TABLE_B into a SAS dataset.  If you need it back into EXCEL you can export it again.

I would do it like this:

data want ;

  merge table_b (in=in1) table_a (in=in2);

  by COLUMN1 ;

  if in1;

  COLUMN2 = in2 ;

  keep column1 column2 ;

run;

But note that it would make COLUMN2 as a numeric variable with of 0 (false) or 1 (true) rather than the text strings in your example.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 696 views
  • 0 likes
  • 2 in conversation