LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2005, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 31 Oct 2005 22:39:28 +0000
Reply-To:     iw1junk@COMCAST.NET
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Whitlock <iw1junk@COMCAST.NET>
Subject:      Re: proc format value assignment oddity - missing values
Comments: cc: pchoate <paulchoate61@YAHOO.COM>

Paul,

I see you have some good answers. I think several years ago Peter Lund gave a SUGI paper on formats in which he discussed the problem. Over the years I have developed the following conventions for using quote marks in SAS.

1) Never use single quotes unless you have to, i.e. to hide macro triggers. (65% doesn't matter, 30% either matters or will when modified, 5% must be single quotes and they will stick out as important.)

2) Never use "" to mean " " - usually they mean the same in SAS, but not always. (options formdlim=""; and inside double quotes are some other cases.)

The reason that it did not matter whether you used one blank or multiple blanks comes from the fact that SAS character variables have a fixed length space filled when a value is short. The function TRIM would be needed far more often in SAS code without the convention that trailing blanks compare equal.

Ian Whitlock ================ Date: Sun, 30 Oct 2005 10:47:27 -0800 Reply-To: pchoate <paulchoate61@YAHOO.COM> Sender: "SAS(r) Discussion" From: pchoate <paulchoate61@YAHOO.COM> Organization: http://groups.google.com Subject: proc format value assignment oddity - missing values Comments: To: sas-l Content-Type: text/plain; charset="iso-8859-1" Question for proc freq wonks - Generally, missing character values in SAS can be represented by either '' (no blanks), ' ' (single blank), or ' ' (many blanks). In comparisons there usually aren't any functional differences between them. The way I think about it is that a character variable must be a least length 1, and trailing blanks are ignored, and so all blank values are treated as ' ', and SAS internally equates '' with ' ', and so any comparison of two missing character values equate regardless of length. I was looking at the distribution of missing values in some data and so coded the following format and freq: proc format; value $MISS '' = 'Missing' other = 'Not Msg'; proc freq ; tables clientid*age / missing; format clientid age $miss.; run; Although the Age column had missing values they weren't shown - the blanks equated to 'Not Msg', and so found that in Proc Freq '' does not equate to ' '. I tried: proc format; value $MISS ' ' = 'Missing' /* note the blank */ other = 'Not Msg'; proc freq ; tables clientid*age / missing; format clientid age $miss.; run; I got the expected results. I also tried more blanks than would equate and they matched as expected: proc format; /* age is $5 client is $9 */ value $MISS ' ' = 'Missing' other = 'Not Msg'; proc freq ; tables clientid*age / missing; format clientid age $miss.; run;

On the left side of a proc format value statement assignment, does '' have any meaning? Is it '00'x rather than '20'x? Thanks to all that reply.


Back to: Top of message | Previous page | Main SAS-L page