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

19 1 14000 Y
45 1 65000 G
72 2 35000 B
31 1 44000 Y
58 2 83000 W

 

That's my data for 'car customers' and each field representing age, sex, income, and preferred color.

 

Below is my code:

 

DATA cars;
	INFILE '/folders/myfolders/sasuser.v94/universecars.txt';
	INPUT Age Gen Income CarColor $;
RUN;

PROC FORMAT;
	VALUE agegroup	13 -< 20 = 'Teen'
					20 -< 65 = 'Adults'
					65 - high = 'Senior';
	VALUE gender	1 = 'Male';
					2 = 'Female';
	VALUE incrange	0 -< 20000 = 'Extreme Low'
					20000 -< 40000 = 'Low'
					40000 -< 60000 = 'Med'
					60000 -< 80000 = 'High'
					80000 - HIGH = 'Extreme High';
	VALUE $color	'y' = 'Yellow'
					'G' = 'Green'
					'B' = 'Blue'
					'W' = 'White';
					
PROC PRINT data=cars;
	FORMAT Age agegroup. Gen gender. Income incrange. CarColor $color.;
RUN;

 

 

and the results when I run, does not interprete number 2 in 'sex' field as 'female'.

Strange enough, 1 works as a 'male'. and it doesnot work for Y, neither.

 

Obs

Age

Gen

Income

CarColor

1

Teen

Male

Extreme Low

Y

2

Adults

Male

High

Green

3

Senior

2

Low

Blue

4

Adults

Male

Med

Y

5

Adults

2

Extreme High

White

 

 

Please help

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

remove semicolon  after male

 

VALUE gender	1 = 'Male';
					2 = 'Female';

 

View solution in original post

5 REPLIES 5
jimmychoi
Obsidian | Level 7

I get this message in Log

83 ! 2 = 'Female';
_
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
novinosrin
Tourmaline | Level 20

remove semicolon  after male

 

VALUE gender	1 = 'Male';
					2 = 'Female';

 

novinosrin
Tourmaline | Level 20

check for case sensitivity of format vs value

 

	VALUE $color	'y' = 'Yellow'
					'G' = 'Green'
					'B' = 'Blue'
					'W' = 'White';

  

jimmychoi
Obsidian | Level 7
Works like a charm thank you so much
Why didn't I find that???
and thanks again for the comments for the case sensitivity of formats, I will work on that
novinosrin
Tourmaline | Level 20

lol happens to me too. Just a syntax issue. Have fun!

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
  • 5 replies
  • 714 views
  • 0 likes
  • 2 in conversation