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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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