Help using Base SAS procedures

Accepted Solution

Read in html data from Census website

Reply
Highlighted
Community Manager
Posts: 3,101

Re: Read in html data from Census website

[ Edited ]

If you're running this from SAS Enterprise Guide, you can do something like this.

 

First, download the file into a known location on your server.  I reference the SASUSER location here, but you could choose another path that you know you can navigate to.

 

filename census "%sysfunc(getoption(sasuser))/raw.txt";
proc http
 url="https://www2.census.gov/programs-surveys/demo/tables/geographic-mobility/2015/county-to-county-migration-2011-2015/county-to-county-migration-flows/MCDxMCD_ager_US.txt"
 method="GET"
 out=census;
run;

I prefer PROC HTTP instead of FILENAME URL.  It's a bit more code, but you have more control over the file name and destination.

 

In the Servers list, navigate your server's file system and find the file you just downloaded.

 

serverlist.png

 

Double-click the file to add to your project.  Then right-click and select Import Data.

 

import.png

 

In the Import Data wizard, select the Fixed Width option to set your column boundaries, then add the column names/attributes on the next page.

 

importfw.png

 

The wizard will generate DATA step code that you can then incorporate back into your original program -- and thus automate this step in the future.  I recently wrote a How To article about importing fixed-width column data here.  With this large file, be sure to follow my steps for tuning the performance of the import step.

 

Update: Follow @Reeza's instructions for the documented file layout -- save my steps here for when you have a file without any code template for the layout Smiley Happy

SAS Super FREQ
Posts: 8,951

Re: Read in html data from Census website

Posted in reply to ChrisHemedinger
Hi, Chris:
Remember that some EG users do not have WRITE access to the SASUSER library. This is why the certification guides have special instructions for how to bypass SASUSER and point to a different location.

cynthia
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 16 replies
  • 253 views
  • 7 likes
  • 7 in conversation