Create variable in sql update

Reply
Contributor
Posts: 73

Create variable in sql update

Hi,

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 a.id = b.id


Can this be done using Proc sql?


Thanks

Thomas

Respected Advisor
Posts: 3,887

Re: Create variable in sql update

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
  • 149 views
  • 0 likes
  • 2 in conversation