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

Hi all,

I am using an already established format program to create a format for specific character codes.  An example of the code is the following:

"1400 "-"1729 " = "TUMOR"

I have a couple of questions:

1) what is the purpose of the space (here, there is one after the 0 and after the 9).  I thought it could be a wildcard, but did not see any documentation about this.  Also, I has always used a ":" in the past if I needed a wildcard feature...

2) I am getting the code "140" to format as "TUMOR"  I am wondering if this should be the case, and if it is related to the spaces in the range provided.

Any thoughts would be helpful - thanks!

-Katie

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Katie,

"140" should not be in range.  That's the one puzzling part of the results.  Could it be that you had a slightly different string, such as "140." or "14O" instead of "140"?

The extra blanks at the end would not normally make a difference.  Technically, there are some characters that are smaller than a blank, but you won't find them on the keyboard.  If such characters appear in the data, however, that extra blank would come into play.

Good luck.

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User

Spaces should have no effect.

Note that ranges in character formats are defined lexigraphically.

Note that '15' would be in your list because it is between '1400' and '1729' because the first digits are the same and '5' is between '4' and '7'.

Also '14500' would be in your list because the code for '5' is after the code for '0' and the code for '4' is before the code for '7'.

Thanks, Tom.

So, in this case, should '140' also be within the range?  That would suggest that 140=1400, right?

Thanks!

-Katie

Astounding
PROC Star

Katie,

"140" should not be in range.  That's the one puzzling part of the results.  Could it be that you had a slightly different string, such as "140." or "14O" instead of "140"?

The extra blanks at the end would not normally make a difference.  Technically, there are some characters that are smaller than a blank, but you won't find them on the keyboard.  If such characters appear in the data, however, that extra blank would come into play.

Good luck.

Thank you all for your help.  You are right, 140 should not be picked up by the format.  Thanks for the information on the blanks, and that characters could be smaller than a blank.  I think what I was missing here was that a blank value is actually less than a 0 (correct?), and therefore in the above code, 14 would not be in the range, but 15 would.

Thanks again for all of your help!

-Katie

robertrao
Quartz | Level 8

Hi Tom,

In you example I understood why 15 will be in the list of the range 1400-1728

But I dint understand why 14500 will be also be included in that range???????

Could you explain one more time please??

Thanks

Tom
Super User Tom
Super User

Perhaps if you convert the digits to letters it will be clearer. Or better yet let SAS do it for you.

data _null_;

  length x low high $8;

  input x low high ;

  between = (low <= x <= high);

  put (x low high between) (=);

  x   = translate(x,'ABCEDEFGHI','0123456789');

  low = translate(low,'ABCEDEFGHI','0123456789');

  high = translate(high,'ABCEDEFGHI','0123456789');

  put (x low high between) (=);

  put;

cards;

14500 1400 1700

140 1400 1700

run;

x=14500 low=1400 high=1700 between=1

x=BDEAA low=BDAA high=BGAA between=1

x=140 low=1400 high=1700 between=0

x=BDA low=BDAA high=BGAA between=0

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2681 views
  • 3 likes
  • 4 in conversation