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

Hello, I have the following dataset

 

data test;
infile datalines;
input Est_inc $3.;
datalines;
008
015
020
040
051
060
061
070
150
;
run;

 

The values are character but are clean data. I want to specify range as follows, but unsuccesful. Please help.


proc format;
value $ emp;
"008"-"020"="8-20"
"040"-"060"="40-60"
"061"-"150"="61-150"
;
run;

 

Regards,

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

It looks like you just need to clean up the syntax of your VALUE statement.  

 

  • Remove the space after the dollar sign.  It might work with the space there, but probably not.
  • Remove the semicolon after EMP.  The VALUE statement doesn't end until later.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

It looks like you just need to clean up the syntax of your VALUE statement.  

 

  • Remove the space after the dollar sign.  It might work with the space there, but probably not.
  • Remove the semicolon after EMP.  The VALUE statement doesn't end until later.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Personally I avoid using formats, but even more so when dealing with numbers as characters.  Would the text "8" be considered between "008" and "024"?  Textually its not.  Is there a reason for the format need?  Why not just convert to numeric and use numeric ranging - makes more sense as your really dealing with numeric data.  Nothing stopping you keeping both, text and num, and using num.

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
  • 2 replies
  • 896 views
  • 1 like
  • 3 in conversation