<?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: Creating new Variable value based on current observation in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Creating-new-Variable-value-based-on-current-observation/m-p/213004#M3040</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;Hi there.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;Perhaps you could try this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;data in;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; input ID @@;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; datalines;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; 1 2 3 4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;data want; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; set in;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; attrib New_ID length=$10.; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; if ID in(1:3) then New_ID='USA';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; else New_ID='Germany';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;proc print noobs; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Jul 2015 00:36:50 GMT</pubDate>
    <dc:creator>Miracle</dc:creator>
    <dc:date>2015-07-29T00:36:50Z</dc:date>
    <item>
      <title>Creating new Variable value based on current observation</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Creating-new-Variable-value-based-on-current-observation/m-p/213003#M3039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have the following data set. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;I want to create a new variable call New_ID and give them a corresponding Character value if ID=1-3 then New_ID='USA'; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;if ID=4 then New_ID='Germany'. Can someone tell me if I can do it without format function.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; New_ID&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; USA&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; USA&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; USA&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Germany &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Thanks,able&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 00:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Creating-new-Variable-value-based-on-current-observation/m-p/213003#M3039</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2015-07-29T00:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new Variable value based on current observation</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Creating-new-Variable-value-based-on-current-observation/m-p/213004#M3040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;Hi there.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;Perhaps you could try this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;data in;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; input ID @@;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; datalines;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; 1 2 3 4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;data want; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; set in;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; attrib New_ID length=$10.; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; if ID in(1:3) then New_ID='USA';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; else New_ID='Germany';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'courier new', courier;"&gt;proc print noobs; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 00:36:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Creating-new-Variable-value-based-on-current-observation/m-p/213004#M3040</guid>
      <dc:creator>Miracle</dc:creator>
      <dc:date>2015-07-29T00:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new Variable value based on current observation</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Creating-new-Variable-value-based-on-current-observation/m-p/213005#M3041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Wong, It worked perfect. Can you please tell me what should I do if there are 3 category?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want the New_ID as: &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;value 1 to 6 = Germany, 7 to 11 = USA, 12 to 15 = Germany and missing value (.) = N/A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I wrote the following code and it's not working. Can you please help. Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; set in;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; attrib New_ID length=$10.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; if ID in(7:11) then New_ID='USA';&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; &lt;SPAN style="font-family: 'courier new', courier; font-size: 16px; background-color: #ffffff;"&gt;if ID in(.) then New_ID='N/A';&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;else New_ID='Germany';&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;proc print noobs; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 18:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Creating-new-Variable-value-based-on-current-observation/m-p/213005#M3041</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2015-07-29T18:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new Variable value based on current observation</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Creating-new-Variable-value-based-on-current-observation/m-p/213006#M3042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are getting all "Germany" values except for .&lt;/P&gt;&lt;P&gt;because of&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 16px; background-color: #ffffff;"&gt;if ID in(.) then New_ID='N/A';&lt;/SPAN&gt; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; font-style: inherit; font-weight: inherit;"&gt;else New_ID='Germany';&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; font-style: inherit; font-weight: inherit;"&gt;ANY value of ID at this point other than . will yield "Germany".&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; font-style: inherit; font-weight: inherit;"&gt;You want need:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; font-style: inherit; font-weight: inherit;"&gt;&amp;nbsp; if ID in(7:11) then New_ID='USA';&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; font-style: inherit; font-weight: inherit;"&gt;&amp;nbsp; else &lt;SPAN style="font-family: 'courier new', courier; font-size: 16px; background-color: #ffffff;"&gt;if ID in(.) then New_ID='N/A';&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt; font-style: inherit; font-weight: inherit;"&gt;else New_ID='Germany';&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 18:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Creating-new-Variable-value-based-on-current-observation/m-p/213006#M3042</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-07-29T18:22:15Z</dc:date>
    </item>
  </channel>
</rss>

