Hi Yu -=20
If I may add a comment - you seem to be confusing SAS informats and SAS
formats. SAS formats are for writing data to a printer, screen, or a =
file.
SAS informats are for reading data from a file. You don't need an =
informat
for reading numeric data if it is in one of the following standard =
numeric
forms. SAS defaults to the standard numeric informat 32. (alias =
best32.):=20
data reading;
input nums; /* default informat (32.) */
cards;
-32
32.3
32.2333
32e6
3200.21
.32e6
;
proc print; /*some different output formats*/
format nums best12.;
proc print;
format nums 12.2;
proc print;
format nums 6.;
run;
Input numeric data representing money may have commas and dollar signs. =
For
this SAS has the comma (alias dollar) informat:
data reading;
input money comma12.; /* comma12. informat */
cards;
-321,321
-$321,321
3,200.213
$3,200.21
;
proc print; /*some different output formats*/
format money best12.;
proc print;
format money comma12.2;
proc print;
format money dollar12.2;
run;
You can read about informats here:
http://support.sas.com/onlinedoc/913/docMainpage.jsp
SAS OnlineDoc Contents
Base SAS
SAS Language Reference: Concepts
SAS Variables
SAS Variable Attributes
Also look at=20
SAS OnlineDoc Contents
Base SAS
SAS Language Reference: Dictionary
Dictionary of Language Elements
Informats
COMMAw.d Informat
w.d Informat
hth
Paul Choate
DDS Data Extraction
(916) 654-2160
-----Original Message-----
From: owner-sas-***@listserv.uga.edu
[mailto:owner-sas-***@listserv.uga.edu]On Behalf Of Yu Zhang
Sent: Tuesday, July 26, 2005 3:58 PM
To: SAS-***@LISTSERV.UGA.EDU
Cc: Yu Zhang
Subject: commaxw.d format
Dear All,
I am confused by using commaxw.d format to read data. Here is an =
example
code:
data reading;
input sales commax5.1;
cards;
32
32.3
32.23
;
proc print;
run;
The output is shown here:
Obs sale
1 3.2
2 32.3
3 322.3
Only second number was correctly read.
SAS documentation says:"Writes numeric values with a period that =
separates
every three digits and a comma that separates the decimal fraction " =
for
the first number only 2 digits, SAS still put a period into the number. =
I
just wonder How SAS will put the period into the number?
Any helps are appreciated!
Yu
________________________________________________________________________=
____
______________________________________________________
This e-mail may be privileged and/or confidential, and the sender does =
not
waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it
contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return =
e-mail or
otherwise) immediately.
Ce courrier =E9lectronique est confidentiel et prot=E9g=E9. =
L'exp=E9diteur ne
renonce pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des =
renseignements
qu'il contient par une personne autre que le (les) destinataire(s)
d=E9sign=E9(s) est interdite.
Si vous recevez ce courrier =E9lectronique par erreur, veuillez m'en =
aviser
imm=E9diatement, par retour de courrier =E9lectronique ou par un autre =
moyen.