LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 17 Apr 2006 09:05:09 -0400
Reply-To:     Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Subject:      Re: Reading Data

That works only if it is always in line 14. If it is not, you might read all lines in a char variable (to get no errors) and look for a trigger. You could use the verify function for that. If you find a line with only chars like " 0123456789." that is a data-line (?)

so data a; infile "...." truncover; input string char200.; if not verify(string," 1234567890.") then do; year=input(scan(string,1," "),8.); y =input(scan(string,2," "),8.); .... output; end; drop string; run;

That is independant of where the table is located, also if there are some lines in the table which are no data, eg. headers after a page-break, that is also ignored. If you want to read that automaticly, means: first extract the structure (variable names, labels,...) then read the data, that is a thing for a macro. In that case tell us.

On Mon, 17 Apr 2006 18:35:49 +0800, =?UTF-8?B?6IuX54Kz56Wl?= <032015214@FUDAN.EDU.CN> wrote:

>hi sum, > >You can use 'firstobs' when you import data form ascii.txt: > >data rose; >infile 'c:\ascii.txt' firstobs=14; >input YEAR Y X2 X3 X4 X5; >run; >> Hi All, >> Suppose i have a data file with descriptions of the variables like >> this: >> Table 7.6 >> Demand for Roses >> >> YEAR = Year and Quarter >> Y = Quantity of Roses Sold, Dozens >> X2 = Average Wholesale Price of Roses, $ Per Dozen >> X3 = Average Wholesale Price of Carnations, $ Per Dozen >> X4 = Average Weekly Family Disposable Income, $ Per Week >> X5 = Trend Variable Taking Values of 1, 2, and so on, for the >> Period >> 1971.3 to 1975.3 in the Detroit Metropolitan Area >> >> YEAR Y X2 X3 X4 X5 >> 1971.3 11484 2.26 3.49 158.11 1 >> 1971.4 9348 2.54 2.85 173.36 2 >> 1972.1 8429 3.07 4.06 165.26 3 >> 1972.2 10079 2.91 3.64 172.92 4 >> 1972.3 9240 2.73 3.21 178.46 5 >> 1972.4 8862 2.77 3.66 198.62 6 >> 1973.1 6216 3.59 3.76 186.28 7 >> >> >> How can i read this data set stored as ASCII .txt file in C: drive so >> that SAS will read relevant portions of the data only for analysis? >> >>


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