<?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: convert state abbreviations to full names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533783#M146393</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/258707"&gt;@klj81&lt;/a&gt;&amp;nbsp; does this not work for you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data customers10;
	length statename $50;
	input First $ Last $ City $ State $ Zip;
	statename=stnamel(state);
datalines;
Tyler Smith Upland PA 91783
Samantha Davis Montclair NJ 07163
Michael Rodriguez Metuchen NJ 08840
David Jorge Frenso CA 93650
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 07 Feb 2019 23:34:08 GMT</pubDate>
    <dc:creator>ChrisBrooks</dc:creator>
    <dc:date>2019-02-07T23:34:08Z</dc:date>
    <item>
      <title>convert state abbreviations to full names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533742#M146371</link>
      <description>&lt;P&gt;I have a data set that consists of names, addresses, state, zip, and phone number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to convert the states from their two letter abbreviations to the full name of the state.&lt;/P&gt;&lt;P&gt;I tried using the stnamel function but I am not sure how to do it for multiple states;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, when I use&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;State=stnamel('PA');&lt;/P&gt;&lt;P&gt;put state;&lt;/P&gt;&lt;P&gt;State=stname ('CA')l;&lt;/P&gt;&lt;P&gt;put state;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All states in the State column turn to Pennsylvania.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a newbie to SAS and could not find examples of this.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 21:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533742#M146371</guid>
      <dc:creator>klj81</dc:creator>
      <dc:date>2019-02-07T21:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: convert state abbreviations to full names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533757#M146379</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You didn't show all your code or your data structure, so I'm not sure what you mean by "how to do it for multiple states" -- every row has a different state. As an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data state;
  length state_name $50;
  infile datalines;
  input name $ stcode $;
  state_name = stnamel(stcode);
  putlog _n_= name= stcode= state_name=;
return;
datalines;
Alan  NC
Barb  SC
Cyndi OH
Dave  DC
Eddy  WA
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results in this in the log:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="stnamel.png" style="width: 549px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26964iD974CBAF7425C051/image-size/large?v=v2&amp;amp;px=999" role="button" title="stnamel.png" alt="stnamel.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You might mean that you have multiple states for every observation? Perhaps you have something like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mult_var.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26965iB4DF5BA18096809E/image-size/large?v=v2&amp;amp;px=999" role="button" title="mult_var.png" alt="mult_var.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;which just means you have a function call for every variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 21:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533757#M146379</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-02-07T21:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: convert state abbreviations to full names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533778#M146390</link>
      <description>&lt;P&gt;Thanks for the response Cynthia!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll enter some of my code/data to try to explain a little better....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data customers10;&lt;/P&gt;&lt;P&gt;input First $ Last $ City $ State $ Zip;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;Tyler Smith Upland PA 91783&lt;/P&gt;&lt;P&gt;Samantha Davis Montclair NJ 07163&lt;/P&gt;&lt;P&gt;Michael Rodriguez Metuchen NJ 08840&lt;/P&gt;&lt;P&gt;David Jorge Frenso CA 93650&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to get the full name for the states like 'California' but every time I have tried the stnamel function I think I have done it incorrectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 23:16:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533778#M146390</guid>
      <dc:creator>klj81</dc:creator>
      <dc:date>2019-02-07T23:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: convert state abbreviations to full names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533781#M146392</link>
      <description>&lt;P&gt;Please show your entire data step. One line of code does not indicate when a&amp;nbsp; value is assigned in relation to when it is written to a data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some example input data may also be needed.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/258707"&gt;@klj81&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a data set that consists of names, addresses, state, zip, and phone number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to convert the states from their two letter abbreviations to the full name of the state.&lt;/P&gt;
&lt;P&gt;I tried using the stnamel function but I am not sure how to do it for multiple states;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, when I use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;State=stnamel('PA');&lt;/P&gt;
&lt;P&gt;put state;&lt;/P&gt;
&lt;P&gt;State=stname ('CA')l;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;&amp;lt;= There is a typo on this line&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;put state;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All states in the State column turn to Pennsylvania.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am a newbie to SAS and could not find examples of this.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The code you posted also would have an error for 'CA'.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 23:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533781#M146392</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-07T23:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: convert state abbreviations to full names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533783#M146393</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/258707"&gt;@klj81&lt;/a&gt;&amp;nbsp; does this not work for you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data customers10;
	length statename $50;
	input First $ Last $ City $ State $ Zip;
	statename=stnamel(state);
datalines;
Tyler Smith Upland PA 91783
Samantha Davis Montclair NJ 07163
Michael Rodriguez Metuchen NJ 08840
David Jorge Frenso CA 93650
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 23:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533783#M146393</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2019-02-07T23:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: convert state abbreviations to full names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533788#M146395</link>
      <description>&lt;P&gt;By any chance are you having issues when the City is something like San Francisco?&lt;/P&gt;
&lt;P&gt;Your example data step code would be reading Francisco into state and not CA.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 00:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-state-abbreviations-to-full-names/m-p/533788#M146395</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-08T00:07:48Z</dc:date>
    </item>
  </channel>
</rss>

