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.
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;
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.