Help using Base SAS procedures

set same value to all cells - proc sql

Accepted Solution Solved
Reply
Super Contributor
Posts: 401
Accepted Solution

set same value to all cells - proc sql

Hi,  I'm merging 2 tables in proc sql and I want the new  table to have a forced value in one field.

So mergin Table A and Table B to create Table C, and I want to force a field called MG_typ found in Table A to be all = 'Residential'.. how can I do that..

similar to simply assigning MG_typ = 'Residential' in base SAS. 

Thanks



Accepted Solutions
Solution
‎10-10-2014 03:59 PM
Super User
Posts: 19,791

Re: set same value to all cells - proc sql

Depends on if the variable exists in the other table at all or in both already.

If in neither table then the following will work:

select 'Residential' as MG_typ

If it's missing in all of table B, but present in All of Table A you could use the coalesce function:

select coalesce(MG_type, "Residential") as MG_Type

Otherwise some sort of Case Statement is required.

View solution in original post


All Replies
Trusted Advisor
Posts: 1,228

Re: set same value to all cells - proc sql

Use Case statement.

Solution
‎10-10-2014 03:59 PM
Super User
Posts: 19,791

Re: set same value to all cells - proc sql

Depends on if the variable exists in the other table at all or in both already.

If in neither table then the following will work:

select 'Residential' as MG_typ

If it's missing in all of table B, but present in All of Table A you could use the coalesce function:

select coalesce(MG_type, "Residential") as MG_Type

Otherwise some sort of Case Statement is required.

Super Contributor
Posts: 401

Re: set same value to all cells - proc sql

Thank you Reeza

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 209 views
  • 0 likes
  • 3 in conversation