<?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: Splitting a city and zip code into 2 variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-city-and-zip-code-into-2-variables/m-p/435161#M108062</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data agentd;
informat customer $2. date1 yymmdd10. date2 yymmdd10. city $30. zipcode 6. city_zipcode $30.;
input customer $ date1 date2 city_zipcode &amp;amp; $30.;
city = scan(city_zipcode, 1, ',');
zipcode = input(scan(city_zipcode, -1, ' '), 5.);
format date1 date2 mmddyy8.;
datalines;
1. 2014-03-11 2014-05-31 Bremen, KS, 66412
2. 2015-08-06 2015-09-02 Little River, KS, 67457
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Feb 2018 04:15:03 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2018-02-08T04:15:03Z</dc:date>
    <item>
      <title>Splitting a city and zip code into 2 variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-city-and-zip-code-into-2-variables/m-p/435156#M108060</link>
      <description>&lt;P&gt;Class assignment that I am stuck on. &amp;nbsp;Sorry if this is simple. &amp;nbsp;I need to split the last variable in the data City, state, zip code into 2 variables city and zip code. &amp;nbsp;In the code I am calling the variables city and zipcode. &amp;nbsp;I can not figure out how to have sas read the city separate from the zip code. &amp;nbsp;I have tried the input statement that is blocked out with the /*.......*/ &amp;nbsp;(this was done without the format statement and the other input statement shown below) but the city length is not the same distance. &amp;nbsp;I tried a dlm comma statement but not all variables have commas separating,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the copied information statement to no avail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data agentd;&lt;BR /&gt;informat customer $1. date1 yymmdd10. date2 yymmdd10. city $30. zipcode 6.;&lt;BR /&gt;/*input customer $ date1 : yymmdd10. date2 : yymmdd10. city $14. zipcode;*/&lt;BR /&gt;input customer date1 date2 city zipcode;&lt;BR /&gt;format date1 date2 mmddyy8.;&lt;BR /&gt;datalines;&lt;BR /&gt;1. &amp;nbsp;2014-03-11. &amp;nbsp;2014-05-31. &amp;nbsp;Bremen, KS, 66412&lt;BR /&gt;2. &amp;nbsp;2015-08-06 &amp;nbsp; 2015-09-02. &amp;nbsp;Little River, KS, 67457&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Id love any suggestions from the masses of experts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 03:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-city-and-zip-code-into-2-variables/m-p/435156#M108060</guid>
      <dc:creator>bennessmith</dc:creator>
      <dc:date>2018-02-08T03:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a city and zip code into 2 variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-city-and-zip-code-into-2-variables/m-p/435161#M108062</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data agentd;
informat customer $2. date1 yymmdd10. date2 yymmdd10. city $30. zipcode 6. city_zipcode $30.;
input customer $ date1 date2 city_zipcode &amp;amp; $30.;
city = scan(city_zipcode, 1, ',');
zipcode = input(scan(city_zipcode, -1, ' '), 5.);
format date1 date2 mmddyy8.;
datalines;
1. 2014-03-11 2014-05-31 Bremen, KS, 66412
2. 2015-08-06 2015-09-02 Little River, KS, 67457
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Feb 2018 04:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-city-and-zip-code-into-2-variables/m-p/435161#M108062</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-02-08T04:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a city and zip code into 2 variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-city-and-zip-code-into-2-variables/m-p/435170#M108068</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data agentd;
informat customer $1. date1 yymmdd10. date2 yymmdd10.;
input customer date1 date2 city_ipcode $30.;
city= substr(city_ipcode,1,length(city_ipcode)-length(scan(city_ipcode,-1,',')));
zipcode=input(scan(city_ipcode,-1,','),6.);
format date1 date2 mmddyy8.;
datalines;
1. 2014-03-11   2014-05-31  Bremen, KS, 66412
2. 2015-08-06   2015-09-02  Little River, KS, 67457
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Feb 2018 06:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-city-and-zip-code-into-2-variables/m-p/435170#M108068</guid>
      <dc:creator>rvsidhu035</dc:creator>
      <dc:date>2018-02-08T06:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a city and zip code into 2 variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-city-and-zip-code-into-2-variables/m-p/435228#M108092</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data agentd;
informat customer $2. date1 yymmdd10. date2 yymmdd10. city $30. zipcode 6. city_zipcode $30.;
input customer $ date1 date2 city_zipcode &amp;amp; $30.;
city = prxchange('s/,\s*\d+$//',1,strip(city_zipcode));
zipcode = input(scan(city_zipcode, -1, ' '), 5.);
format date1 date2 mmddyy8.;
datalines;
1. 2014-03-11 2014-05-31 Bremen, KS, 66412
2. 2015-08-06 2015-09-02 Little River, KS, 67457
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Feb 2018 12:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-city-and-zip-code-into-2-variables/m-p/435228#M108092</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-02-08T12:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a city and zip code into 2 variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-city-and-zip-code-into-2-variables/m-p/435262#M108116</link>
      <description>&lt;P&gt;Thank you so very much. &amp;nbsp;so awesome to see the various ways to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I see that I need to add a variable to this dataset with the same value &amp;nbsp;how would I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each customer I want there to be a variable named AGENT. &amp;nbsp; Each customer of this data set will have the value for AGENT of D.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know how to add a computed value but not how to add this added consistent value. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finding this group is incredible&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 14:24:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-city-and-zip-code-into-2-variables/m-p/435262#M108116</guid>
      <dc:creator>bennessmith</dc:creator>
      <dc:date>2018-02-08T14:24:45Z</dc:date>
    </item>
  </channel>
</rss>

