Desktop productivity for business analysts and programmers

If id of Table_A is in id of Table_b Then X

Reply
New Contributor
Posts: 4

If id of Table_A is in id of Table_b Then X

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.

Super User
Super User
Posts: 6,372

Re: If id of Table_A is in id of Table_b Then X

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.

Ask a Question
Discussion stats
  • 1 reply
  • 165 views
  • 0 likes
  • 2 in conversation