BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wheddingsjr
Pyrite | Level 9

Hi all

 

I ran this query but i get the following error message. Can anyone assist me in correcting this?

	, R.RACE01DSC as Race_Ethnicity LABEL= 'Race/Ethnicity'
	,CASE WHEN RACE01DSC = 'ASIAN' THEN 'Asian'
		  WHEN RACE01DSC = 'BLACK OR AFRICAN AMERICAN' THEN 'Black or African American'
		  WHEN RACE01DSC = 'Hispanic or Latino' THEN 'Hispanic or Latino'
		  WHEN RACE01DSC LIKE ('WHITE%') THEN 'White or Caucasian'
	      WHEN RACE01DSC IN ('Declined', 'Unavailable') THEN 'Unknown'
		  WHEN RACE01DSC IS NULL THEN 'Unknown'
		  ELSE 'Other' END AS 'RACE'


______
22
ERROR 22-322: Expecting a name.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
That's a logical error then.
Run a PROC FREQ on the original column, RACE01DSC, to show us the original values. If they don't match because of case differences is usually the first issue. Second could be invisible spaces.

View solution in original post

5 REPLIES 5
Reeza
Super User

Remove quotes around your variable name, RACE.

END AS RACE

 

Or add an N after it to tell SAS it's a valid variable name not a character string.

END as 'RACE'n

@wheddingsjr wrote:

Hi all

 

I ran this query but i get the following error message. Can anyone assist me in correcting this?

	, R.RACE01DSC as Race_Ethnicity LABEL= 'Race/Ethnicity'
	,CASE WHEN RACE01DSC = 'ASIAN' THEN 'Asian'
		  WHEN RACE01DSC = 'BLACK OR AFRICAN AMERICAN' THEN 'Black or African American'
		  WHEN RACE01DSC = 'Hispanic or Latino' THEN 'Hispanic or Latino'
		  WHEN RACE01DSC LIKE ('WHITE%') THEN 'White or Caucasian'
	      WHEN RACE01DSC IN ('Declined', 'Unavailable') THEN 'Unknown'
		  WHEN RACE01DSC IS NULL THEN 'Unknown'
		  ELSE 'Other' END AS 'RACE'


______
22
ERROR 22-322: Expecting a name.


 

wheddingsjr
Pyrite | Level 9

Thanks Reeza and Kurt. That made the query run, however, the new column is populated with "Unknown" regardless what the Race_Ethnicty column is. How does that happen?

wheddingsjr
Pyrite | Level 9
Sorry, its populated with "OTHER"
Reeza
Super User
That's a logical error then.
Run a PROC FREQ on the original column, RACE01DSC, to show us the original values. If they don't match because of case differences is usually the first issue. Second could be invisible spaces.

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 895 views
  • 0 likes
  • 3 in conversation