LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (February 2010, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sat, 27 Feb 2010 22:08:12 -0500
Reply-To:   art297@NETSCAPE.NET
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:   Re: Format in SAS
Comments:   To: mark.chase91@yahoo.in
In-Reply-To:   <530832.99206.qm@web95707.mail.in.yahoo.com>
Content-Type:   text/plain; charset="utf-8"; format=flowed

Mark,

Based on the sample of data you sent me, I would think that the following will do what you want to accomplish:

data _null_; infile 'c:\Sas\period1_sales_data3.dat.'; input stuff $35.; put stuff; cards; RX00023609/11/200905:54:52AT3600 1 RX00023709/11/200912:03:14AT3600 1 RX00023810/11/200910:18:34AP3965 1 RX00023910/11/200911:51:29AP3965 1 RX00025511/11/200923:32:19AP3965 1 ;

options datestyle=dmy; data period1; infile 'c:\Sas\period1_sales_data3.dat.'; Input TransactionID $ 1-8 DateofSale $ 9-18 TimeofSale $ 19-26 LaptopModel $ 27-32 UnitsSold 33-35; DateTimeofSale = inputn(DateofSale||":"||TimeofSale,'anydtdtm',19); SameDayDelivery=timepart(DateTimeofSale)<='15:00't; format DateTimeofSale datetime21.; run;

Art -----Original Message----- From: Mark Chase <mark.chase91@yahoo.in> To: Arthur Tabachneck <art297@netscape.net> Sent: Sat, Feb 27, 2010 9:05 pm Subject: Re: Format in SAS

Hello Arthur ,

I used the code

libname sc 'c:\Cwa'; data  period1;    infile 'c:\Cwa\period1_sales_data.dat.';    Input    TransactionID $1-8          DateofSale    $9-18          TimeofSale   $19-26          LaptopModel  $27-32          UnitsSold     33-35; proc print data = period1; run;

and got ( part ) :

                          Transaction                  Timeof    Laptop   Units                   Obs       ID        DateofSale     Sale     Model     Sold                     52    RX000236     09/11/2009   05:54:52   AT3600     1                    53    RX000237     09/11/2009   12:03:14   AT3600     1                    54    RX000238     10/11/2009   10:18:34   AP3965     1                    55    RX000239     10/11/2009   11:51:29   AP3965     1

Then i used code :

data result; Â Â Â Â set period1; Â Â Â DateTimeofSale = DateofSale||":"||TimeofSale; run; proc print data = result(drop= DateofSale TimeofSale); run;

and got as output :

   Transaction   Laptop   Units                     Obs       ID        Model     Sold     DateTimeofSale                      154    RX000248     AP3965     1     10/11/2009:14:17:28                     155    RX000253     AP3965     1     11/11/2009:12:22:09                     156    RX000254     AP3965     1     11/11/2009:13:11:21                     157    RX000255     AP3965     1     11/11/2009:23:32:19                 Â

I want to extract only those dates on which I've time ">= 15:00:00" in order to find proprtion of transactions that qualify for same day delivery and I used code :

data PrepForTabulate /view=PrepForTabulate; Â set result; Â DateofSale=datepart(DateTimeofSale); Â SameDayDelivery=timepart(DateTimeofSale)<='15:00't; run; proc print data = PrepForTabulate; run;

The log ( part ) :-

NOTE: Invalid numeric data, DateTimeofSale='03/11/2009:11:27:53' , at line 127 column 23. NOTE: Invalid numeric data, DateTimeofSale='03/11/2009:11:27:53' , at line 128 column 28. TransactionID=RX000152 DateofSale=Â TimeofSale=11:27:53 LaptopModel=AP3965 UnitsSold=5 DateTimeofSale=03/11/2009:11:27:53 SameDayDelivery=1 _ERROR_=1 _N_=1

 Kindly guide , mark

------------------------------------------------------------ From: Arthur Tabachneck <art297@netscape.net> To: mark <mark.chase91@yahoo.in> Cc: SAS-L@LISTSERV.UGA.EDU Sent: Sun, 28 February, 2010 4:18:11 AM Subject: Re: Format in SAS

Mark,

Without seeing a sample of your data, it's impossible to know what will actually work.

That said, the following creates what is hopefully close to what your data actually looks like, and then inputs it. I had to guess at some of the lengths and formats as there were a couple of what appeared to be errors/inconsistencies in your example. Let the list know if this does, in fact, solve your problem.

*Note: I changed the file name to ....data2 so that you wouldn't accidentally overwrite your actual data;

data _null_; Â file 'c:\Cwa\period1_sales_data2.dat'; Â informat stuff $80.; Â format stuff $80.; Â input stuff; Â put stuff; Â cards; 0000000110APR2004:10:00:01brandx1010 0000000215DEC2009:07:42:01brandy2121 ;

data period1 (drop=in_:); Â infile 'c:\Cwa\period1_sales_data2.dat'; Â input TransactionID $ 1-8 Â Â Â Â in_DateTimeofSale $ 9-26 Â Â Â Â LaptopModel $ 27-32 Â Â Â Â UnitsSold 33-35 Â Â Â Â Warranty 36; Â DateTimeofSale=inputn(in_DateTimeofSale,'datetime',18); Â DateofSale=datepart(DateTimeofSale); Â TimeofSale=timepart(DateTimeofSale); Â format DateTimeofSale datetime21.; Â format TimeofSale time5.; Â format DateofSale date9.; run;

proc print data=period1; run;

HTH, Art ------------ On Feb 27, 2:03 pm, mark <mark.chas...@yahoo.in> wrote: > hello , > > I'm using the code :- > > data  period1; >     infile 'c:\Cwa\period1_sales_data.dat.'; >     Input  TransactionID $1-8 >             DateofSale     $9-18 >             TimeofSale   $19-26 >         @9 DateTimeofSale ANYDTDTM16. >             LaptopModel  $27-32 >           UnitsSold    33-35 >             Warranty      36; > format DateTimeofSale datetime21. > ; > > proc print data=period1; > run; > > I want to concatenate the varaibels DateofSale and TimeofSale.The new > varaible in above code gives no entry. > > Kindly  guide, > markc

------------------------------------------------------------ The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.


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