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

Most text books say that the smallest values are the missing values: ""(character) and .(numeric)

Apparently, this applies only to regular unpacked data.

The byte that represents packed data seems to be smaller than the usual missing ""(character) value.

Such bytes don't have any meaning and can appear to be symbols like:

Null, start of heading, start of text, end of text, punch off, horizontal tab...

I thought that such symbols would be greater than missing "", but apparently they're less than or equal to missing.

This is in z/OS EBCDIC using SAS 9.2, but I expect similar results in Windows ASCII.

Specific example: trying to read a packed decimal field conditionally:

   if substr(_infile_,1,3)>'' then input @1 var1  pd3. ;

This line doesn't produce an error, but the IF expression is always false, so it looks like packed bytes are less than or equal to missing.

Please correct me if I'm wrong.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

MISSING does not apply for CHARACTER strings.

Your IF statement is testing if the ASCII codes for the first three characters in the input stream is larger than the ASCII code for a single space.

So if the first byte of your binary packed decimal value happens to have a hexadecimal value less than '20'X then the IF will be false.

If I store 10 into PD3. format I get the value '000010'x. This is definitely less than ' ' as binary zero that is in the first byte is less than the binary 32 stored as the value of space.

If I try to store numeric missing into PD3. format I get the value '800000'x.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

MISSING does not apply for CHARACTER strings.

Your IF statement is testing if the ASCII codes for the first three characters in the input stream is larger than the ASCII code for a single space.

So if the first byte of your binary packed decimal value happens to have a hexadecimal value less than '20'X then the IF will be false.

If I store 10 into PD3. format I get the value '000010'x. This is definitely less than ' ' as binary zero that is in the first byte is less than the binary 32 stored as the value of space.

If I try to store numeric missing into PD3. format I get the value '800000'x.

agoldma
Pyrite | Level 9

The Definition of Missing Values recognizes "missing character value as a blank space", so I would rather say that SAS considers the space character " " to be equivalent to an empty character string "".

This is the part that I forgot. Thank you for reminding me about this.

If "" = " ", and " "='20'x in ASCII and '40'x in EBCDIC, then there are many opportunities for some packed bytes to be smaller than '20'x and even more opportunities to be smaller than '40'x.

Also, I should've read the last 2 sentences of Order of Missing Values in SAS Help.

In my specific example, the only thing that I'm trying to avoid is spaces, so I should've excluded only spaces instead of a range of characters:

if substr(_infile_,1,3) ne '' then input @1 var1  pd3. ;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 767 views
  • 0 likes
  • 2 in conversation