Help using Base SAS procedures

Character Formatting - Use of space

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

Character Formatting - Use of space

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


Accepted Solutions
Solution
‎07-05-2013 06:45 PM
Super User
Posts: 5,082

Re: Character Formatting - Use of space

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


All Replies
Super User
Super User
Posts: 6,500

Re: Character Formatting - Use of space

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'.

Occasional Contributor
Posts: 8

Re: Character Formatting - Use of space

Thanks, Tom.

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

Thanks!

-Katie

Solution
‎07-05-2013 06:45 PM
Super User
Posts: 5,082

Re: Character Formatting - Use of space

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.

Occasional Contributor
Posts: 8

Re: Character Formatting - Use of space

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

Super Contributor
Posts: 1,040

Re: Character Formatting - Use of space

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

Super User
Super User
Posts: 6,500

Re: Character Formatting - Use of space

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

☑ This topic is SOLVED.

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

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