BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KAZ
Obsidian | Level 7 KAZ
Obsidian | Level 7

The US Census Bureau makes TIGER/Line shapefiles available via a series of FTP sites.  The files are freely available and no account is needed to access the FTP site.  I am attempting to write a program that downloads those files.

 

I presumed a filename ftp statement was the way to go, but am running into problems.

 

* Copy files from US Census website to the specified directory;
filename _bcin ftp "ftp://ftp2.census.gov/geo/tiger/TIGER2010/ZCTA5/2010/tl_2010_24_zcta510.zip";
filename _bcout "C:\Temp\tl_2010_24_zcta510.zip" recfm=n;
data _null_;
   length msg $ 384;
   rc=fcopy('_bcin', '_bcout');
   if rc=0 then
      put 'Copied _bcin to _bcout.';
   else do;
      msg=sysmsg();
      put rc= msg=;
   end;
run;

quit;

I received the follwoing error: rc=5660215 msg=ERROR: Open failed for file _BCIN.

What is the proper filenane ftp statement for the remote file?

 

(alternative question: downloading US Census files must be a common task for mapping appications.  Are there any available macros out there that accomplishes this?)

 

 

I am running SAS v9.4, TS1M4.

1 ACCEPTED SOLUTION

Accepted Solutions
FriedEgg
SAS Employee
filename _bcin ftp 'tl_2010_24_zcta510.zip'
cd='/geo/tiger/TIGER2010/ZCTA5/2010'
host='ftp2.census.gov'
user='anonymous'
passive binary recfm=s;

 

and, if fcopy doesn't work you can use a very simple data step instead

 

data _null_;
infile _bcin;
file _bcout;
input;
put _infile_;
run;

View solution in original post

1 REPLY 1
FriedEgg
SAS Employee
filename _bcin ftp 'tl_2010_24_zcta510.zip'
cd='/geo/tiger/TIGER2010/ZCTA5/2010'
host='ftp2.census.gov'
user='anonymous'
passive binary recfm=s;

 

and, if fcopy doesn't work you can use a very simple data step instead

 

data _null_;
infile _bcin;
file _bcout;
input;
put _infile_;
run;
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2394 views
  • 1 like
  • 2 in conversation