Help using Base SAS procedures

SAS SQL COlumn name with pipes and apostrophe

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

SAS SQL COlumn name with pipes and apostrophe

ok i know its odd, but i have a field name:

 

D.DISPUTE_ID||'0'||R.REASON_NUMB

 

how do I deal with that in a PROC SQL column name?

 

thanks!


Accepted Solutions
Solution
‎10-27-2017 03:52 PM
Super User
Posts: 13,563

Re: SAS SQL COlumn name with pipes and apostrophe


StaticFX wrote:

ok i know its odd, but i have a field name:

 

D.DISPUTE_ID||'0'||R.REASON_NUMB

 

how do I deal with that in a PROC SQL column name?

 

thanks!


Beat up whoever created it.

 

It looks like someone attempted to concatenate some values to create a variable but did it incorrectly, possibly in a macro

If that is the actual name you should be able to reference it using the name literal syntax: "D.DISPUTE_ID||'0'||R.REASON_NUMB"n

 

I would be very tempted to rename the variable (and fix any process assigning such a name) as typing such a name is asking for syntax errors.

View solution in original post


All Replies
PROC Star
Posts: 311

Re: SAS SQL COlumn name with pipes and apostrophe

I don't know what you mean by this. That looks like the code is concatenating dispute_id from one table (alias d) and reason_numb from another (alias r) with a "0" in the middle. If this is just part of a select statement, I don't know what needs to change (other than possible issues with leading blanks). If it's part of a create table, you'd just want to do "D.DISPUTE_ID||'0'||R.REASON_NUMB AS your_desired_name," for the syntax. 

Contributor
Posts: 27

Re: SAS SQL COlumn name with pipes and apostrophe

Posted in reply to collinelliot

thats what it is doing in the original query...

 

but thats the actual column name now lol..I am afraid to rename the field in the original SQL code that creates the table because the table is used by who knows how many other scripts...

 

I would rename it myself but I cant get it to accept it lol

 

SELECT ID, [D.DISPUTE_ID||'0'||R.REASON_NUMB], INVOICE_DATE FROM COMBINED;

SELECT ID, "D.DISPUTE_ID||'0'||R.REASON_NUMB", INVOICE_DATE FROM COMBINED;

SELECT ID, `D.DISPUTE_ID||'0'||R.REASON_NUMB`, INVOICE_DATE FROM COMBINED;

 

nothing works..

 

 

Solution
‎10-27-2017 03:52 PM
Super User
Posts: 13,563

Re: SAS SQL COlumn name with pipes and apostrophe


StaticFX wrote:

ok i know its odd, but i have a field name:

 

D.DISPUTE_ID||'0'||R.REASON_NUMB

 

how do I deal with that in a PROC SQL column name?

 

thanks!


Beat up whoever created it.

 

It looks like someone attempted to concatenate some values to create a variable but did it incorrectly, possibly in a macro

If that is the actual name you should be able to reference it using the name literal syntax: "D.DISPUTE_ID||'0'||R.REASON_NUMB"n

 

I would be very tempted to rename the variable (and fix any process assigning such a name) as typing such a name is asking for syntax errors.

PROC Star
Posts: 311

Re: SAS SQL COlumn name with pipes and apostrophe

I concur with this: "Beat up whoever created it." 

 

 

Contributor
Posts: 27

Re: SAS SQL COlumn name with pipes and apostrophe

ahhh i dint see the n after thank you! that was driving me nuts!! Smiley Happy I am renaming it from the query too lol

 

 

PS: im looking for the person who started it! lol

Super User
Posts: 13,563

Re: SAS SQL COlumn name with pipes and apostrophe


StaticFX wrote:

ahhh i dint see the n after thank you! that was driving me nuts!! Smiley Happy I am renaming it from the query too lol

 

 

PS: im looking for the person who started it! lol


 

Start with the person in your shop refers to "macros" the most.

☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 373 views
  • 3 likes
  • 3 in conversation