06-16-2017 12:58 PM
This caused some unexpected pain: one cannot use the variable USER in SQL:
data one ;
user = 1 ;
proc sql ;
proc sql ;
I did not see that coming and it was suprising given how many data sets must have variable USER.
NOTE: SAS (r) Proprietary Software 9.4 (TS1M1)
NOTE: This session is executing on the X64_S08R2 platform.
NOTE: Additional host information:
X64_S08R2 WIN 6.1.7601 Service Pack 1 Server
06-16-2017 01:11 PM
Documented under SQL reserved words:
06-16-2017 01:12 PM - edited 06-16-2017 01:15 PM
You will see that for a few special keywords that ANSI SQL defines and SAS supports. You will have similar problems in other implementations of SQL. The easiest fix is to add the alias to the variable name reference. In addition to using the name literal approach you can add the DQUOTE=ANSI option to PROC SQL and then it will treat values in double quotes as meaning the name of field.
Try this program
proc sql dquote=ansi ; select user 'Bare user' , "user" 'DQUOTED user' , 'user'n 'NLITERAL user' , a.user 'Alias included' , * from sashelp.class(obs=1 rename=(name=user)) a ; quit;