<?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: How do I create new variable from another variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519594#M3835</link>
    <description>&lt;P&gt;Thank you so very much SuryaKiran&lt;/P&gt;</description>
    <pubDate>Fri, 07 Dec 2018 22:52:41 GMT</pubDate>
    <dc:creator>sasnewbie5</dc:creator>
    <dc:date>2018-12-07T22:52:41Z</dc:date>
    <item>
      <title>How do I create new variable from another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519560#M3825</link>
      <description>&lt;P&gt;&lt;STRONG&gt;****&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt;address;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;INPUT#&lt;STRONG&gt;1&lt;/STRONG&gt;@&lt;STRONG&gt;1&lt;/STRONG&gt;line1 $50.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;#&lt;STRONG&gt;2&lt;/STRONG&gt;@&lt;STRONG&gt;1&lt;/STRONG&gt;line2 $50.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;#&lt;STRONG&gt;3&lt;/STRONG&gt;@&lt;STRONG&gt;1&lt;/STRONG&gt;line3 $50.;&lt;/P&gt;&lt;P&gt;DATALINES;&lt;/P&gt;&lt;P&gt;Mr.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Jason&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;Simmons&lt;/P&gt;&lt;P&gt;123&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Sesame&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Street&lt;/P&gt;&lt;P&gt;Madison, WI&lt;/P&gt;&lt;P&gt;Dr.&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Justin&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Case&lt;/P&gt;&lt;P&gt;78&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;River&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Road&lt;/P&gt;&lt;P&gt;Flemington, NJ&lt;/P&gt;&lt;P&gt;Ms. Marilyn&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Crow&lt;/P&gt;&lt;P&gt;777 Jewell&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Avenue&lt;/P&gt;&lt;P&gt;Pittsburgh,&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;PA&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;****&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the above code, I need to create a new variable called name that contains only the first and last names separated by a comma. For the life of me I cannot seem to figure this one out. Any and all help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;*By the way, I'm using SAS university edition.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 21:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519560#M3825</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-07T21:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create new variable from another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519566#M3826</link>
      <description>&lt;P&gt;Given from your data, if the names are always like ( prefix first name last name ), then using scan will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;name=catx(',',scan(line1,2),scan(line1,3));
&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA address;
INPUT	#1@1 line1 $50.
		#2@1 line2 $50.
		#3@1 line3 $50.;
name=catx(',',scan(line1,2),scan(line1,3));
DATALINES;
Mr.  Jason   Simmons
123  Sesame Street
Madison, WI
Dr.    Justin Case
78    River Road
Flemington, NJ
Ms. Marilyn  Crow
777 Jewell   Avenue
Pittsburgh,    PA
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Dec 2018 21:17:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519566#M3826</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-12-07T21:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create new variable from another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519569#M3827</link>
      <description>&lt;P&gt;Thanks so much SuryaKiran!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An additional question is how would I go about creating a new variable called street so that it contains the street name in only uppercase letters while also replacing Road/Street/Avenue with Rd./St./Ave.?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 21:29:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519569#M3827</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-07T21:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create new variable from another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519586#M3829</link>
      <description>&lt;P&gt;UPCASE() to convert to upper case and for find replace you can use index() to find and tranwrd() to replace.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA address;
INPUT	#1@1 line1 $50.
		#2@1 line2 $50.
		#3@1 line3 $50.;
name=catx(',',scan(line1,2),scan(line1,3));
Street=upcase(line2);

if index(street,'STREET') then street=tranwrd(street,'STREET','ST.');
if index(street,'ROAD') then street=tranwrd(street,'ROAD','RD.');
if index(street,'AVENUE') then street=tranwrd(street,'AVENUE','AVE.');

DATALINES;
Mr.  Jason   Simmons
123  Sesame Street
Madison, WI
Dr.    Justin Case
78    River Road
Flemington, NJ
Ms. Marilyn  Crow
777 Jewell   Avenue
Pittsburgh,    PA
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Dec 2018 22:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519586#M3829</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-12-07T22:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create new variable from another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519594#M3835</link>
      <description>&lt;P&gt;Thank you so very much SuryaKiran&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 22:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519594#M3835</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-07T22:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create new variable from another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519607#M3836</link>
      <description>&lt;P&gt;Please note that you will want to check some of the results carefully as names, both people and streets are some of the worst data out there in common usage.&lt;/P&gt;
&lt;P&gt;You can have last names like "Le Blanc" "von Richtofen". In which case scan for third word in something like&lt;/P&gt;
&lt;P&gt;Mr. Pierre Le Blanc&lt;/P&gt;
&lt;P&gt;will yield Le as the last name, missing the Blanc part. Language and culture or origin can make this even more complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And street names like "Highway to the Gods" have the same issue. And that is if you actually have the luxury of &lt;STRONG&gt;always&lt;/STRONG&gt; having a number preceding the street name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might see you can actually get you input data in some form of delimited data file. Hopefully the original collector did not put all of the name information in a single piece of text (proper data entry for names into separate fields for first, last , middle name and form of address (Mr Mrs Ms Dr Senator what have you) has been known for a long time.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 23:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-create-new-variable-from-another-variable/m-p/519607#M3836</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-07T23:48:01Z</dc:date>
    </item>
  </channel>
</rss>

