Go Back   Rhinocerus > Newsgroup > Newsgroup comp.soft-sys.sas

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 05-02-2006, 02:50 AM
Jiann-Shiun Huang
Guest
 
Posts: n/a
Default Re: Reading External Rawdata (.txt)

Sai:

Try the following code and output follows the code.

data April;
infile 'E:\SAS_assignments\dataoneapril.txt' firstobs=5 obs=24;
input Name $31. @33 StartDate yymmdd10. @53 EndDate yymmdd10. @73
Send
Receive Total Duration Traffic;
format startdate worddate18.;
format enddate worddate18.;
label Name='Plan Name';
run;

proc print;
run;

***** Output *****
The SAS System
11:32 Monday, May 1, 2006 1

Obs Name StartDate
EndDate

1 Plan -HOME500 : Speed -256 Kbps April 29, 2006
April 29, 2006
2 Plan -HOME500 : Speed -256 Kbps April 28, 2006
April 28, 2006
3 Plan -HOME500 : Speed -256 Kbps April 28, 2006
April 28, 2006
4 Plan -HOME500 : Speed -256 Kbps April 28, 2006
April 28, 2006
5 Plan -HOME500 : Speed -256 Kbps April 27, 2006
April 27, 2006
6 Plan -HOME500 : Speed -256 Kbps April 27, 2006
April 27, 2006
7 Plan -HOME500 : Speed -256 Kbps April 27, 2006
April 27, 2006
8 Plan -HOME500 : Speed -256 Kbps April 27, 2006
April 27, 2006
9 Plan -HOME500 : Speed -256 Kbps April 27, 2006
April 27, 2006
10 Plan -HOME500 : Speed -256 Kbps April 27, 2006
April 27, 2006
11 Plan -HOME500 : Speed -256 Kbps April 26, 2006
April 26, 2006
12 Plan -HOME500 : Speed -256 Kbps April 26, 2006
April 26, 2006
13 Plan -HOME500 : Speed -256 Kbps April 26, 2006
April 26, 2006
14 Plan -HOME500 : Speed -256 Kbps April 26, 2006
April 26, 2006
15 Plan -HOME500 : Speed -256 Kbps April 26, 2006
April 26, 2006
16 Plan -HOME500 : Speed -256 Kbps April 25, 2006
April 25, 2006
17 Plan -HOME500 : Speed -256 Kbps April 25, 2006
April 25, 2006
18 Plan -HOME500 : Speed -256 Kbps April 25, 2006
April 25, 2006
19 Plan -HOME500 : Speed -256 Kbps April 25, 2006
April 25, 2006
20 Plan -HOME500 : Speed -256 Kbps April 25, 2006
April 25, 2006

Obs Send Receive Total Duration Traffic

1 508 5920 6428 534 6428
2 461 4018 4479 1328 4479
3 16882 20017 36899 2376 2858
4 19164 25529 44693 8260 0
5 497 2299 2796 2101 2796
6 40 85 125 180 125
7 290 1364 1654 1214 1654
8 744 2993 3737 2677 3737
9 385 1781 2166 4699 1794
10 1053 8066 9119 16840 0
11 237 1566 1803 133 1803
12 184 1054 1238 619 1238
13 62 435 497 155 497
14 728 4345 5073 3310 24
15 1309 15085 16394 2720 0
16 218 1193 1411 368 1411
17 33 386 419 106 419
18 536 2801 3337 3237 3337
19 128 633 761 1227 761
20 247 1284 1531 850 1531


J S Huang
1-515-557-3987
fax 1-515-557-2422

>>> <saivs28@GMAIL.COM> 05/01/06 9:14 PM >>>

hi all,

I'm trying to read a rawdata file in SAS. I'm unable to figure out
which is the best input method to read in. I'm giving a sample of the
raw data file(.txt) of 20 obs out of millions of records which are to
be read. Now how am I suppose to read in order to output correctly....

Sample Data:
================================================== =================
Service Name Start Time Stop Time Send[KB] Receive[KB] Total[KB]
Duration[second] Traffic(KB)(excluding night unlimited[For HOME
500/1000/1800/3300 plan only])
Plan -HOME500 : Speed -256 Kbps 2006/04/29 00:33:25 2006/04/29
00:42:19
508 5920 6428 534 6428
Plan -HOME500 : Speed -256 Kbps 2006/04/28 21:52:06 2006/04/28
22:14:14
461 4018 4479 1328 4479
Plan -HOME500 : Speed -256 Kbps 2006/04/28 07:23:25 2006/04/28
08:03:01
16882 20017 36899 2376 2858
Plan -HOME500 : Speed -256 Kbps 2006/04/28 05:05:26 2006/04/28
07:23:06
19164 25529 44693 8260 0
Plan -HOME500 : Speed -256 Kbps 2006/04/27 22:13:46 2006/04/27
22:48:47
497 2299 2796 2101 2796
Plan -HOME500 : Speed -256 Kbps 2006/04/27 22:04:29 2006/04/27
22:07:29
40 85 125 180 125
Plan -HOME500 : Speed -256 Kbps 2006/04/27 14:09:14 2006/04/27
14:29:28
290 1364 1654 1214 1654
Plan -HOME500 : Speed -256 Kbps 2006/04/27 12:43:09 2006/04/27
13:27:46
744 2993 3737 2677 3737
Plan -HOME500 : Speed -256 Kbps 2006/04/27 07:46:17 2006/04/27
09:04:36
385 1781 2166 4699 1794
Plan -HOME500 : Speed -256 Kbps 2006/04/27 03:04:50 2006/04/27
07:45:30
1053 8066 9119 16840 0
Plan -HOME500 : Speed -256 Kbps 2006/04/26 21:37:31 2006/04/26
21:39:44
237 1566 1803 133 1803
Plan -HOME500 : Speed -256 Kbps 2006/04/26 12:49:44 2006/04/26
13:00:03
184 1054 1238 619 1238
Plan -HOME500 : Speed -256 Kbps 2006/04/26 09:47:44 2006/04/26
09:50:19
62 435 497 155 497
Plan -HOME500 : Speed -256 Kbps 2006/04/26 07:06:10 2006/04/26
08:01:20
728 4345 5073 3310 24
Plan -HOME500 : Speed -256 Kbps 2006/04/26 06:16:09 2006/04/26
07:01:29
1309 15085 16394 2720 0
Plan -HOME500 : Speed -256 Kbps 2006/04/25 22:02:19 2006/04/25
22:08:27
218 1193 1411 368 1411
Plan -HOME500 : Speed -256 Kbps 2006/04/25 14:25:42 2006/04/25
14:27:28
33 386 419 106 419
Plan -HOME500 : Speed -256 Kbps 2006/04/25 11:24:00 2006/04/25
12:17:57
536 2801 3337 3237 3337
Plan -HOME500 : Speed -256 Kbps 2006/04/25 10:44:21 2006/04/25
11:04:48
128 633 761 1227 761
Plan -HOME500 : Speed -256 Kbps 2006/04/25 10:27:38 2006/04/25
10:41:48
247 1284 1531 850 1531

================================================== =================
1. how should I read all the columns correctly?
2. Once I read then how can I drop columns as per my requirement? ( do
i need to use DROP option)?
3. I'm also showing a sample of code which i've written to
read..though
its just a simple one...but the problem arising is like the date
values
are shown as April 2, 2006 for both StartDate and EndDate-- is it bcos
the column is datetime? and the values for certain columns are missing
while reading from the file and showing up in inappropriate columns
such as Send value is showing up in Total while Send is showing a
period in the column.So also with Receive values showing up in
Duration
column.

data april;
infile 'E:\SAS_assignments\dataoneapril.txt' firstobs=5 obs=26;
input Name $31. StartDate yymmdd10. @32 EndDate yymmdd10. @52 Send
Receive Total Duration
Traffic;
format startdate worddate18.;
format enddate worddate18.;
label Name='Plan Name';
run;

4.Apart from the above stated reasons, how am I supposed decide which
input method to read correctly and i'm having facing problems when I
try to use
a. Column Input- then i'm encountering glitches bcos the column
lengths are varying for each column
b. List Input - Seems appropriate but the data is messy in the last
5
columns
c. Or how do we use mixed style input?
d. How do we use Colon modifier for this case? can we use?


Thanx in advance... Cheers.
SAI
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 05-02-2006, 08:15 AM
saivs28@gmail.com
Guest
 
Posts: n/a
Default Re: Reading External Rawdata (.txt)

hello JS Huang,

Thanx it worked... I need to clarify a few more things before I proceed
to work....with the results.

1. If I want to read certain columns with INPUT statement then how can
I do it? Say for eg. The columns I want to read are Plan, Startdate,
Enddate, Total, then how do I specify? I tried giving the @84 Total but
the column is getting overlapped with the previous columns value which
is extending into this column(eg.3rd/4th row in the data i've given)

2. I would also like to know how to read the format in the Startdate
column which is datetime format? When i'm reading with teh following
format then its showing output as 01JAN1960:04:41:57 for all the
rows...

data april;
infile 'E:\SAS_assignments\dataoneapril.txt' firstobs=5
obs=24;
input Name $31. @33 StartDate yymmdd10. @53 EndDate yymmdd10.
@84 Total Duration Traffic;
/*informat startdate datetime20.;*/
format startdate datetime19.;
format enddate worddate18.;
label Name='Plan Name' StartDate='Start Date' Enddate='End
Date';
run;

proc print data=april;run;

RESULT Window:
^^^^^^^^^^^^^^^^^^^^^

The SAS System 1

Obs Name StartDate

1 Plan -HOME500 : Speed -256 Kbps 01JAN1960:04:42:00
2 Plan -HOME500 : Speed -256 Kbps 01JAN1960:04:41:59
3 Plan -HOME500 : Speed -256 Kbps 01JAN1960:04:41:59
4 Plan -HOME500 : Speed -256 Kbps 01JAN1960:04:41:59
5 Plan -HOME500 : Speed -256 Kbps 01JAN1960:04:41:58
6 Plan -HOME500 : Speed -256 Kbps 01JAN1960:04:41:58
7 Plan -HOME500 : Speed -256 Kbps 01JAN1960:04:41:58
8 Plan -HOME500 : Speed -256 Kbps 01JAN1960:04:41:58
9 Plan -HOME500 : Speed -256 Kbps 01JAN1960:04:41:58
10 Plan -HOME500 : Speed -256 Kbps 01JAN1960:04:41:57
11 Plan -HOME500 : Speed -256 Kbps 01JAN1960:04:41:57
12 Plan -HOME500 : Speed -256 Kbps 01JAN1960:04:41:57

Obs EndDate Total Duration Traffic

1 April 29, 2006 6428 534 6428
2 April 28, 2006 4479 1328 4479
3 April 28, 2006 7 36899 2376
4 April 28, 2006 9 44693 8260
5 April 27, 2006 2796 2101 2796
6 April 27, 2006 180 125 .
7 April 27, 2006 3737 2677 3737
8 April 27, 2006 2166 4699 1794
9 April 27, 2006 9119 16840 0
10 April 26, 2006 1803 133 1803
11 April 26, 2006 1238 619 1238
12 April 26, 2006 7 155 497

Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: INPUT statement, read external .txt file Nat Wooding Newsgroup comp.soft-sys.sas 0 11-09-2006 09:50 PM
Re: Reading External Rawdata (.txt) nospam@HOWLES.COM (Howard Schreier Newsgroup comp.soft-sys.sas 0 05-03-2006 03:30 PM
Re: Reading External Rawdata (.txt) Choate, Paul@DDS Newsgroup comp.soft-sys.sas 0 05-02-2006 03:56 PM
Reading External Rawdata (.txt) saivs28@gmail.com Newsgroup comp.soft-sys.sas 0 05-02-2006 02:14 AM
Re: Reading Number (?) Data From An External File Rob Rohrbough Newsgroup comp.soft-sys.sas 0 11-22-2005 06:42 PM



All times are GMT. The time now is 05:42 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.