BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Emma_at_SAS
Lapis Lazuli | Level 10

I have some variables with negative values that are assigned for the missing observations. When I assign the value labels in proc format; the first time SAS reaches a negative value faces an error. My list of variables is long with several similar negative observations (-9). Please see my code and error below. Thank you for your suggestions. 

 

	value income
	  1 = "less than 20000"
	  2 = "20000-40000"
	  3 = "40000-60000"
	  4 = "60000-80000"
	  5 = ">80000"
	  -9 = "Don’’t know";
format income income.;
1556 +   9 = "Don’’t know"
         -
         180
ERROR 180-322: Statement is not valid or it is used out of proper order.
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Most likely the error is before line 1556 and it is just at line 1556 that SAS notices something has gone wrong.

Did you my mistake include a semi-colon before that last line?

Did you use something other than a hyphen character for the minus sign?  Try retyping that line, especially if you have copied the lines from a word processing program (or email).

View solution in original post

7 REPLIES 7
Tom
Super User Tom
Super User

Most likely the error is before line 1556 and it is just at line 1556 that SAS notices something has gone wrong.

Did you my mistake include a semi-colon before that last line?

Did you use something other than a hyphen character for the minus sign?  Try retyping that line, especially if you have copied the lines from a word processing program (or email).

Emma_at_SAS
Lapis Lazuli | Level 10
Thank you Tom! Yes, I had an extra semi-colon before that last line but I could not see that until you told me. Thanks
japelin
Rhodochrosite | Level 12

Please provide reproducible data and programs, not excerpts.

PaigeMiller
Diamond | Level 26

Please show us the ENTIRE log for your PROC FORMAT, and not selected pieces.

--
Paige Miller
Emma_at_SAS
Lapis Lazuli | Level 10

Thanks @PaigeMiller  @japelin  @Tom for your thoughts and suggestions

ballardw
Super User

One Problem: Wrong character for single quotes:

-9 = "Don’’t know";

Compare with:

-9 = "Don''t know";

The "curly" quotes are not treated as programming quotes properly.

 

The statement

format income income.;

does not belong in Proc Format. Proc format would not have a variable named income to attach a format to.

 

You would use that format statement in a proc using a data set such as Proc Print, or in data step code to permanently associated the format income with the variable.

 

As mentioned by others: Show the log for the entire procedure or data step that shows that error. Copy the entire text from the Log and paste into a text box opened on the forum with the </> icon.

 

BTW,  if you need a single quote to appear inside a value surrounded by double quotes you do not need to double them such as

	  -9 = "Don't know";

You would need the two single quotes in don't if you were only using single quotes all the time

	  -9 = 'Don''t know';
Emma_at_SAS
Lapis Lazuli | Level 10

Thank you @ballardw. lots of good points!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 479 views
  • 2 likes
  • 5 in conversation