<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: web scraping in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/web-scraping/m-p/497600#M131933</link>
    <description>Thank you for this useful tip! It seems like SASHELP is a useful folder, not just sample data.</description>
    <pubDate>Thu, 20 Sep 2018 22:43:53 GMT</pubDate>
    <dc:creator>jojozheng</dc:creator>
    <dc:date>2018-09-20T22:43:53Z</dc:date>
    <item>
      <title>web scraping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/web-scraping/m-p/497495#M131875</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;need to scrap data from this website&amp;nbsp;&lt;A href="https://www.addresses.com/zipcodes" target="_blank"&gt;https://www.addresses.com/zipcodes&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I need to scrap all US states zip codes, I don't want to copy&amp;amp;past 56 times by manual. Anyone knows how to to do it? Thank you.&lt;/P&gt;&lt;P&gt;I want all cloumns in following page, but I don't want to manually do it. If I do it manually, I need to click states to search over 50 times...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="2018-09-20 12_51_24-AL ZIP Code Lookup _ Addresses.com.png" style="width: 565px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23416i5DC28F4F578AD3A1/image-size/large?v=v2&amp;amp;px=999" role="button" title="2018-09-20 12_51_24-AL ZIP Code Lookup _ Addresses.com.png" alt="2018-09-20 12_51_24-AL ZIP Code Lookup _ Addresses.com.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 17:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/web-scraping/m-p/497495#M131875</guid>
      <dc:creator>jojozheng</dc:creator>
      <dc:date>2018-09-20T17:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: web scraping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/web-scraping/m-p/497539#M131890</link>
      <description>&lt;P&gt;Unfortunately, SAS will not be your best tool for web scraping.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I recommend using something like the Scraper Chrome add-on : &lt;A href="https://chrome.google.com/webstore/detail/scraper/mbigbapnjcgaffohmbkdlecaccepngjd?hl=en" target="_blank"&gt;https://chrome.google.com/webstore/detail/scraper/mbigbapnjcgaffohmbkdlecaccepngjd?hl=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This allows you to highlight any table on a webpage, right-click and hit "scrape", and you can then export the table as a CSV file. You can then import that CSV file into SAS and begin analyzing the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also pip install the BeautifulSoup4 package in Python if you would like to automatically web scrape certain pages, however it can sometimes be extremely tedious and if you are simply trying to scrape some data and perform some analyses on it, I recommend using something like the Scraper Chrome add-on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS unfortunately is not the best tool to web scrape data. For example, the following code scrapes only the zip code portion of the table you wanted to scrape from&amp;nbsp;&lt;A href="https://www.addresses.com/zip-codes-by-state/alabama" target="_self"&gt;https://www.addresses.com/zip-codes-by-state/alabama&lt;/A&gt; :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;filename HTMLtext "C:\Users\daduva\Desktop\WebScrape\HTML_Output.txt";


proc http
	method='GET'
	url="https://www.addresses.com/zip-codes-by-state/alabama"
	out=HTMLtext;
run;

data zipcodes;
infile "C:\Users\daduva\Desktop\WebScrape\HTML_Output.txt" TRUNCOVER dlm='"';
input @'&amp;lt;a href="/zip-code-lookup/' zipcode :$30. @;
run;

proc sort data=zipcodes NODUP;
by zipcode;
run;&lt;/PRE&gt;
&lt;P&gt;I hope this post was helpful.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 19:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/web-scraping/m-p/497539#M131890</guid>
      <dc:creator>danielduval0</dc:creator>
      <dc:date>2018-09-20T19:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: web scraping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/web-scraping/m-p/497541#M131891</link>
      <description>&lt;P&gt;Maybe scraping a website is not what you want to do...have you tried the Zipcode dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=sashelp.zipcode;&lt;BR /&gt;where statecode='AL';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...or other SAS-provided resources&amp;nbsp;&lt;A href="https://support.sas.com/downloads/download.htm?did=122546" target="_blank"&gt;https://support.sas.com/downloads/download.htm?did=122546&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 19:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/web-scraping/m-p/497541#M131891</guid>
      <dc:creator>JasonDiVirgilio</dc:creator>
      <dc:date>2018-09-20T19:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: web scraping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/web-scraping/m-p/497597#M131931</link>
      <description>Thank you! I tried the code, it seems like it can catch a part of data, but not all of them. But thank you so much for your help!</description>
      <pubDate>Thu, 20 Sep 2018 22:37:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/web-scraping/m-p/497597#M131931</guid>
      <dc:creator>jojozheng</dc:creator>
      <dc:date>2018-09-20T22:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: web scraping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/web-scraping/m-p/497600#M131933</link>
      <description>Thank you for this useful tip! It seems like SASHELP is a useful folder, not just sample data.</description>
      <pubDate>Thu, 20 Sep 2018 22:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/web-scraping/m-p/497600#M131933</guid>
      <dc:creator>jojozheng</dc:creator>
      <dc:date>2018-09-20T22:43:53Z</dc:date>
    </item>
  </channel>
</rss>

