Date: Fri, 15 Oct 2004 09:04:16 -0400
Reply-To: "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Subject: Re: Need help on format/informat and input/put
On Thu, 14 Oct 2004 20:02:06 -0700, shanky <shankardasm@BLUEBOTTLE.COM>
wrote:
>Hi guys:
>
>I am finding it a bit difficult to understand format and informat as
>in the case of date or price(value in dollars). i do not understand
>when we have to do format and when informat.
>
>Also i need to know when to use input and when to use put
Hi, Shanky,
Here is some basics about sas formats and informats/ put() and input().
1. use format with put (statement or function) and informat with input.
2. Char ---> input +---> Char ---+
| |
+---> Num ---+ put ---> Char
That is, an input to input() or input statement is always a string;
while output of the put() or put statement is always a string.
3. Now sas has only two variable types: character or numeric. no date
types or currency types. Within sas, it is a good idea to keep dates in a
numeric variable. See if following code example helps.
Cheers,
Chang
data one;
/* read character string with an informat.
birthday variable is of numeric type */
input birthday date.;
cards;
31dec59
01jan60
02jan60
;
run;
/* birthday values are just numbers
jan. 1, 1960 is the day zero */
proc print data=one;
run;
/* on log
Obs birthday
1 -1
2 0
3 1
*/
/* if you associate a format to display
the value differently */
proc print data=one;
format birthday mmddyy.;
run;
/*
Obs birthday
1 12/31/59
2 01/01/60
3 01/02/60
*/