DATA Step, Macro, Functions and more

Specifying character Values as Ranges

Accepted Solution Solved
Reply
Contributor
Posts: 64
Accepted Solution

Specifying character Values as Ranges

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,

 


Accepted Solutions
Solution
‎12-06-2016 04:37 AM
Super User
Posts: 5,516

Re: Specifying character Values as Ranges

Posted in reply to sasmaverick

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


All Replies
Solution
‎12-06-2016 04:37 AM
Super User
Posts: 5,516

Re: Specifying character Values as Ranges

Posted in reply to sasmaverick

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.
Super User
Super User
Posts: 7,977

Re: Specifying character Values as Ranges

Posted in reply to sasmaverick

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 172 views
  • 1 like
  • 3 in conversation