BookmarkSubscribeRSS Feed
xun1
Calcite | Level 5

 

OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 proc sql;
70 select Customer as "Customer Name",
_______________
22
71 Amount as "Transaction Amount" format=DOLLAR10.2
____________________
22
ERROR 22-322: Expecting a name.
 
72 from sq.transactionfull
73 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 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 225.59k
OS Memory 19104.00k
Timestamp 09/08/2023 02:25:41 PM
Step Count 154 Switch Count 1
Page Faults 0
Page Reclaims 17
Page Swaps 0
Voluntary Context Switches 7
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 16
 
77
78
79 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
89
 

 

6 REPLIES 6
ballardw
Super User

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.

Amir
PROC Star

Hi,

 

Try placing an "n" after the quoted column name to make it a name literal, e.g.,:

 

"Customer Name"n

Alternatively, remove the quotes and insert an underscore, e.g.:

 

Customer_Name

 

Try the same with all your renamed columns.

 

 

Thanks & kind regards,

Amir.

xun1
Calcite | Level 5

its still error

Amir
PROC Star

Hi,

 

Please ensure you have applied the fix to all necessary columns.

 

If you are still getting the error, then please post the log showing the code and error messages using the Insert Code icon "</>".

 

 

Thanks & kind regards,

Amir.

Kurt_Bremser
Super User

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
Reeza
Super User
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.

 


@xun1 wrote:

 

OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 proc sql;
70 select Customer as "Customer Name",
_______________
22
71 Amount as "Transaction Amount" format=DOLLAR10.2
____________________
22
ERROR 22-322: Expecting a name.
 
72 from sq.transactionfull
73 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 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 225.59k
OS Memory 19104.00k
Timestamp 09/08/2023 02:25:41 PM
Step Count 154 Switch Count 1
Page Faults 0
Page Reclaims 17
Page Swaps 0
Voluntary Context Switches 7
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 16
 
77
78
79 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
89
 

 


 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 3853 views
  • 8 likes
  • 5 in conversation