Date: Tue, 24 Dec 1996 08:09:04 -0800
Reply-To: "Derrick J [Rick] Bates" <DJ_Bates@PNL.GOV>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: "Derrick J [Rick] Bates" <DJ_Bates@PNL.GOV>
Organization: Battelle, Pacific-Northwest National Laboratory, Richland, WA,
USA
Subject: Re: Problem with converting decimal numbers to character text
In article <32bf6e7e.79584@nntp.ix.netcom.com>, BentleyJ@ix.netcom.com
(John E. Bentley) wrote:
> I have numeric variables like 96.1 and 95.7 that I need to convert to
> character variables so that I can recode missing to 'na'.
>
> I've specified the length of the new character variable as $8.
> When I use
>
> charvar=put(numvar,$8.)
>
> it rounds the numeric variable. 96.1 is output as 96 and 95.7 is
> output as 96. How can I keep this from occurring?
>
> Can anyone suggest code that will do what I want done?
>
What is it you want to do
If all your non-missing are of the form you give above you might use
length charvar $8; charvar=numvar; * automagic formatting;
or
length charvar $8; charvar=put(numvar,8.1); * specified formatting;
or
etc., etc., etc.
Another option for getting the 'na' without going to character variables
is using PROC FORMAT;
proc format;
value na . = ' na';
run;
then use
format numvar na.;
when printing or outputting to a file for S to read
-----------------------------------------------------------------
Derrick J. (Rick) Bates | mailto:DJ_Bates@PNL.Gov
Environmental Statistics Group | Voice: 509.375.2740
2400 Stevens Drive, K5-12 | FAX: 509.375.2604
Battelle, Pacific-NW National Lab |
P.O. Box 999, Richland, WA 99352 USA | EVERY POSSIBLE DISCLAIMER
------------------------------------------------------------------
|