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 (February 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 11 Feb 2008 14:30:38 -0500
Reply-To:     Nathaniel.Wooding@DOM.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject:      Re: How to download CSV files off Internet and assemble them in
              one SAS file?
Comments: To: vatodorov <vatodorov@GMAIL.COM>
In-Reply-To:  <0e86e6ca-f5ee-4b8f-9790-69d8b4591350@d21g2000prf.googlegroups.com>
Content-Type: text/plain; charset="US-ASCII"

Your formats are reading through the delimiters. In cases like these, I specify an informat statement and remove the formats from the input;

data; infile NOAA dsd delimiter =',' firstobs=2 LRECL=32767 missover;

informat Time $5. Scale $3. Location $20. County $11. State $2. Lat best12. Lon best12. Comments $174.;

input Time Scale Location County State Lat Lon Comments ;

run;

I tried using a wildcard in the filename but that did not work. I did add some code that will extract the date from the filename. At this point, you could stick this in a macro and as you suggested earlier, set up macro code to execute it for each date and then accumulate them as it processes.

filename NOAA url "http://www.spc.noaa.gov:80/climo/reports/080205_rpts_torn.csv";

data two; length whence $80.; *this will be used to capture the full file name of each file as * it is read. however, this variable must be processed in this * data step in order to capture the name of a file and hence, the * name of the particular instrument.; infile NOAA dsd delimiter =',' firstobs=2 LRECL=32767 missover filename =whence; *filename here is an option on the infile statement;;

informat Time $5. Scale $3. Location $20. County $11. State $2. Lat best12. Lon best12. Comments $174.;

input Time Scale Location County State Lat Lon Comments ;

* now, grab the date; length source $30.;* source will be set to the value of whence;

source=scan(whence,-4,'/._');* parse out the date as a character string; Date = input(source,mmddyy6.); format date mmddyy10.; drop source;

run;

Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977

vatodorov <vatodorov@GMAIL. COM> To Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU Discussion" cc <SAS-L@LISTSERV.U GA.EDU> Subject Re: How to download CSV files off Internet and assemble them in 02/11/2008 01:31 one SAS file? PM

Please respond to vatodorov <vatodorov@GMAIL. COM>

OK, after some error and trial, I figured out two codes. The first one works great, but the second one didn't, I attached both at the bottom.

Here is also a reference to an old topic, that I found in the SAS GOOGLE group: http://groups.google.com/group/comp.soft-sys.sas/browse_thread/thread/a99b6f0870cc929b/a0c07b61d3f56cbc?#a0c07b61d3f56cbc

/****** 1. Works great *******/

filename NOAA http 'http://www.spc.noaa.gov:80/climo/reports/ 080205_rpts_torn.csv';

data file; infile NOAA ; input; file "excelfile.xls"; put _infile_; run; proc import out= WORK.excelfile datafile= "excelfile.xls" dbms=CSV replace; getnames=yes; datarow=2; run;

/******** 2. Doesn't work ***********/

filename NOAA url "http://www.spc.noaa.gov:80/climo/reports/ 080205_rpts_torn.csv";

data; infile NOAA dsd delimiter =',' firstobs=2 LRECL=32767 missover; input Time $5. Scale $3. Location $20. County $11. State $2. Lat best12. Lon best12. Comments $174.; run;

On Feb 11, 12:22 pm, vatodorov <vatodo...@gmail.com> wrote: > Is it possible to use SAS to download CSV tables from the Internet and > assemble the separate files in one SAS table? I would like to download > county data for tornados from the NOAA site, but there are about 1,500 > separate sheets. The names of the tables are the dates for when the > sheets were prepared. I thought that if I can figure out what query to > create to download the data, I can simply use a macro and list all > dates going four years backwards. > > Thank you

----------------------------------------- CONFIDENTIALITY NOTICE: This electronic message contains information which may be legally confidential and/or privileged and does not in any case represent a firm ENERGY COMMODITY bid or offer relating thereto which binds the sender without an additional express written confirmation to that effect. The information is intended solely for the individual or entity named above and access by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.


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