Create OR update a variable in PROC SQL

Accepted Solution Solved
Reply
Contributor
Posts: 41
Accepted Solution

Create OR update a variable in PROC SQL

Hello,

In a PROC SQL statement, I selected several variables (e.g.: select var1, var2, var3, etc...)

Now I need to include in my SQL statement the result of var1 divided by 12 (var1/12) and I would like to either:

  • Update var1 to reflect this new value; or
  • Assign this value to a new variable (e.g.: NewVar1).

How can I achieve this?

Regards,

P.


Accepted Solutions
Solution
‎12-19-2012 05:33 PM
Respected Advisor
Posts: 4,930

Re: Create OR update a variable in PROC SQL

If you are creating a new table :

Update : select var1/12 as var1,...

New variable : select var1/12 as NewVar1,...

If you just want to change the value of Var1 in an existing table :

update myTable set var1 = var1/12;

PG

PG

View solution in original post


All Replies
Solution
‎12-19-2012 05:33 PM
Respected Advisor
Posts: 4,930

Re: Create OR update a variable in PROC SQL

If you are creating a new table :

Update : select var1/12 as var1,...

New variable : select var1/12 as NewVar1,...

If you just want to change the value of Var1 in an existing table :

update myTable set var1 = var1/12;

PG

PG
Regular Contributor
Posts: 184

Re: Create OR update a variable in PROC SQL

PGStats wrote:

... If you just want to change the value of Var1 in an existing table :

update myTable set var1 = var1/12;


But be careful that you run the code exactly once!

PG

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 172 views
  • 0 likes
  • 3 in conversation