Create variable in sql update

Posts: 73

Create variable in sql update


I have a sql-code that works fine in MS SQL server.

It also works in Proc Sql except for creating a variable inside the update script.

I want the code to create a new variable if table a is updated with a variable from table b (=match). The variable should be empty if it is not updated

This is the SQL-code:

update LM as a

set y= b.y,

match = 1  /* creating this variable will not work in proc sql*/

from have b

where =

Can this be done using Proc sql?



Respected Advisor
Posts: 4,736

Re: Create variable in sql update

Posted in reply to bollibompa

Adding, modifying or dropping a column is done in SQL via an ALTER TABLE statement. This is done this way not only in the SAS SQL flavour but also in the SQL flavours of all databases I've worked with so far.

I strongly doubt that MS SQL behaves differently because this is the DDL as part of the SQL ANSI standard. SQL - Wikipedia, the free encyclopedia

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation