If you are trying to create a name literal variable name then the name must always have an N following the name. Otherwise SAS cannot tell that you are attempt to create a name. Also the System option VALIDVARNAME=ANY has to be in effect to use such.
select Customer as "Customer Name"N
same for your other variables.
personally I would recommend assigning a LABEL with that text and not use the name literals. They were mostly added as a way to access variables in external databases that allow spaces and other characters that SAS doesn't use for variables.
It is a good idea to post LOG entries in a text box opened on the forum using the </> icon above the message window to maintain the text formatting and position of things like the diagnostic characters. The main message windows reformat text so that the underscore characters no longer appear under the offending text. In some cases it can be a challenge to tell which bit of a long expression is the offender.
Try placing an "n" after the quoted column name to make it a name literal, e.g.,:
Alternatively, remove the quotes and insert an underscore, e.g.:
Try the same with all your renamed columns.
Thanks & kind regards,
Don't saddle yourself with stupid name literals. Fancy strings belong in labels:
select Customer as customer_name label="Customer Name", Amount as transaction_amount label="Transaction Amount" format=DOLLAR10.2
option validvarname=any; proc sql; select customer as "Customer Name"n, amount as "Transaction Amount"n format=Dollar10.2 from sq.transactionfull where amount>1000 and service ne 'University' order by 2 desc; quit;
What you should actually do:
option validvarname=V7; proc sql; create table temporary as select customer label="Customer Name", amount label= "Transaction Amount" format=Dollar10.2 from sq.transactionfull where amount>1000 and service ne 'University' order by 2 desc; quit; proc print data=temporary labels; run;
SQL doesn't have the concept of labels, SAS does, they are powerful and help you out. If you're using SAS regularly, it's worth understanding them and how to use them.
OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;6869 proc sql;70 select Customer as "Customer Name",_______________2271 Amount as "Transaction Amount" format=DOLLAR10.2____________________22ERROR 22-322: Expecting a name.72 from sq.transactionfull73 where Amount > 1000 and Service ne 'University'74 order by Amount desc;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.75 title "Large Non-Educational Transactions";76 quit;NOTE: The SAS System stopped processing this step because of errors.NOTE: PROCEDURE SQL used (Total process time):real time 0.00 secondsuser cpu time 0.00 secondssystem cpu time 0.00 secondsmemory 225.59kOS Memory 19104.00kTimestamp 09/08/2023 02:25:41 PMStep Count 154 Switch Count 1Page Faults 0Page Reclaims 17Page Swaps 0Voluntary Context Switches 7Involuntary Context Switches 0Block Input Operations 0Block Output Operations 16777879 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;89
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.