<?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: A DATA MANIPULATION QUESTION - Creating a numbering variable. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581547#M165305</link>
    <description>Indents are fun.&lt;BR /&gt;Use SUBSTR() to check the first character of the string. If it's a space you don't increment your counter, otherwise increment your counter. &lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;retain var2 10;&lt;BR /&gt;if substr(var1, 1,1) = " " then var2+10;&lt;BR /&gt;run;</description>
    <pubDate>Thu, 15 Aug 2019 18:16:57 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-08-15T18:16:57Z</dc:date>
    <item>
      <title>A DATA MANIPULATION QUESTION - Creating a numbering variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581543#M165301</link>
      <description>&lt;P&gt;I have a following data-set (Given)&amp;nbsp; &amp;nbsp; &amp;nbsp;with a character variable "var1". Need to create a numeric variable "var2" where the numbering will be same pattern as the (WANT) dataset ( find it on the bottom of this post). the values of "var2" changes when there is no space in-front of the value of "var1". If there is space in-front of the value of :var1" then "var2" keeps the value from the previous iteration.&lt;/P&gt;&lt;P&gt;GIVEN:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var1&lt;/P&gt;&lt;P&gt;---------------&lt;/P&gt;&lt;P&gt;subject died&lt;/P&gt;&lt;P&gt;subject alive&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;struggling&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;sick&lt;/P&gt;&lt;P&gt;In Vacation&lt;/P&gt;&lt;P&gt;Never lived&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Gone for good&lt;/P&gt;&lt;P&gt;Never showed up&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The WANT dataset should be as below,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var2&lt;/P&gt;&lt;P&gt;----------------------&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;---------------------&lt;/P&gt;&lt;P&gt;subject died&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&lt;/P&gt;&lt;P&gt;subject alive&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;struggling&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;sick&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20&lt;/P&gt;&lt;P&gt;In Vacation&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30&lt;/P&gt;&lt;P&gt;Never lived&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 40&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Gone for good&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 40&lt;/P&gt;&lt;P&gt;Never showed up&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 50&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 18:08:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581543#M165301</guid>
      <dc:creator>SAS_Practice</dc:creator>
      <dc:date>2019-08-15T18:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: A DATA MANIPULATION QUESTION - Creating a numbering variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581547#M165305</link>
      <description>Indents are fun.&lt;BR /&gt;Use SUBSTR() to check the first character of the string. If it's a space you don't increment your counter, otherwise increment your counter. &lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;retain var2 10;&lt;BR /&gt;if substr(var1, 1,1) = " " then var2+10;&lt;BR /&gt;run;</description>
      <pubDate>Thu, 15 Aug 2019 18:16:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581547#M165305</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-15T18:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: A DATA MANIPULATION QUESTION - Creating a numbering variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581549#M165306</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/278261"&gt;@SAS_Practice&lt;/a&gt;&amp;nbsp; I like SCAN&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var  $char50.;
cards;
subject died
subject alive
     struggling
     sick
In Vacation
Never lived 
     Gone for good
Never showed up
;

data want;
set have;
if scan(var,1,' ','m')&amp;gt;' ' then var2+10;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Aug 2019 18:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581549#M165306</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-15T18:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: A DATA MANIPULATION QUESTION - Creating a numbering variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581555#M165307</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FIRST function?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not missing(first(var)) then var2+10;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Aug 2019 18:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581555#M165307</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-08-15T18:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: A DATA MANIPULATION QUESTION - Creating a numbering variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581558#M165308</link>
      <description>&lt;P&gt;Guru&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp; &amp;nbsp;That's a great teaser. Well done! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A similar teaser to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp; &amp;nbsp;, char beats substr in golf lol&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if char(var,1)&amp;gt;' ' then var2+10;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 18:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581558#M165308</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-15T18:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: A DATA MANIPULATION QUESTION - Creating a numbering variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581569#M165309</link>
      <description>&lt;P&gt;How about no functions at all?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if var1 &amp;gt;: ' ' then var2 + 10;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Aug 2019 19:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581569#M165309</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-08-15T19:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: A DATA MANIPULATION QUESTION - Creating a numbering variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581572#M165310</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp; Wow. Winner by a mile! Kudos!!!!!!!!&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 19:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581572#M165310</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-15T19:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: A DATA MANIPULATION QUESTION - Creating a numbering variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581701#M165358</link>
      <description>&lt;P&gt;Here is one more way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if var not =: ' ' then var2+10;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Aug 2019 12:29:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-DATA-MANIPULATION-QUESTION-Creating-a-numbering-variable/m-p/581701#M165358</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-08-16T12:29:04Z</dc:date>
    </item>
  </channel>
</rss>

