<?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: Assign separate id for same value of a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402470#M97737</link>
    <description>&lt;P&gt;"it is not working" is not a good diagnostic aide.&amp;nbsp; What is the result you see, vs what you want?&amp;nbsp; Tell us those symptoms, and we'll be here to help diagnose.&amp;nbsp; Take control of your project, and use sas forum as your advisor.&lt;/P&gt;</description>
    <pubDate>Mon, 09 Oct 2017 18:56:33 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-10-09T18:56:33Z</dc:date>
    <item>
      <title>Assign separate id for same value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402389#M97694</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset containing plan_id and plan_type. One plan_id can have multiple plan types.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Plan_ID&lt;/TD&gt;&lt;TD&gt;Plan_Type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;TP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;TP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;MC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;MP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;CA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;MC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;TP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;MP&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, plan_id 2 has three different plan types i.e TP, MC and MP. I want to rename the plan_id if it has more than one plan_type. For example, Plan_id 2 for TP Plan_Type should remain 2 while for MC, it should change to Second_2 and for MP it should change to Third_2. It should look like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Plan_ID&lt;/TD&gt;&lt;TD&gt;Plan_Type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;TP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;TP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Second_2&lt;/TD&gt;&lt;TD&gt;MC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Third_2&lt;/TD&gt;&lt;TD&gt;MP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;CA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Second_3&lt;/TD&gt;&lt;TD&gt;MC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Third_3&lt;/TD&gt;&lt;TD&gt;TP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Fourth_3&lt;/TD&gt;&lt;TD&gt;MP&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please let me know how to program this in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Chandan Mishra&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 15:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402389#M97694</guid>
      <dc:creator>chandan_mishra</dc:creator>
      <dc:date>2017-10-09T15:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Assign separate id for same value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402398#M97697</link>
      <description>&lt;P&gt;Do you want a given plan type to have same "sub-plainid"?&amp;nbsp; Below type MP is the 4th PLANID=3, but the 3rd PLANID=2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about assigning planid=1.1,1.2,1.3,&amp;nbsp;&amp;nbsp; 2.1,2.2, etc&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 15:33:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402398#M97697</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-09T15:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Assign separate id for same value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402401#M97700</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Yes, The plan_id 1.1,2.1,2.2,2.3 etc works. ok let me rephrase&amp;nbsp;the question. The input data looks like this sorted on both plan_id and plan_type :&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Plan_ID&lt;/TD&gt;&lt;TD&gt;Plan_Type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;TP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;MC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;MP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;TP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;CA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;MC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;MP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;TP&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output should look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Plan_ID&lt;/TD&gt;&lt;TD&gt;Plan_Type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1.1&lt;/TD&gt;&lt;TD&gt;TP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2.1&lt;/TD&gt;&lt;TD&gt;MC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2.2&lt;/TD&gt;&lt;TD&gt;MP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2.3&lt;/TD&gt;&lt;TD&gt;TP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3.1&lt;/TD&gt;&lt;TD&gt;CA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3.2&lt;/TD&gt;&lt;TD&gt;MC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3.3&lt;/TD&gt;&lt;TD&gt;MP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3.4&lt;/TD&gt;&lt;TD&gt;TP&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know how to solve this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Chandan Mishra&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 15:39:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402401#M97700</guid>
      <dc:creator>chandan_mishra</dc:creator>
      <dc:date>2017-10-09T15:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Assign separate id for same value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402442#M97719</link>
      <description>&lt;P&gt;And what have you tried so far?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have tried nothing, consider a DATA step, in which the SET statement reads a sorted dataset (by planid), and is accompanied by a BY PLANID statement.&amp;nbsp; Then all you need to do is to increment the newplanid&amp;nbsp;by 0.1&amp;nbsp; (or by 0.01 if you expect 10 or more plan types for a given id).&amp;nbsp; Whenever you encounter the first record for a given PLANID, reset the newplanid to planid+.1.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 17:39:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402442#M97719</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-09T17:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Assign separate id for same value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402447#M97724</link>
      <description>&lt;PRE&gt;&lt;BR /&gt;data want1;
	set have;
	by plan_id;

	retain a+0.1;

	plan_id=plan_id +a;
	
	if last.plan_id then plan_id=plan_id+0.1;
	drop a;
run;&lt;/PRE&gt;&lt;P&gt;I have used this code. But this is not working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Chandan Mishra&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 17:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402447#M97724</guid>
      <dc:creator>chandan_mishra</dc:creator>
      <dc:date>2017-10-09T17:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Assign separate id for same value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402470#M97737</link>
      <description>&lt;P&gt;"it is not working" is not a good diagnostic aide.&amp;nbsp; What is the result you see, vs what you want?&amp;nbsp; Tell us those symptoms, and we'll be here to help diagnose.&amp;nbsp; Take control of your project, and use sas forum as your advisor.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 18:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402470#M97737</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-09T18:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Assign separate id for same value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402489#M97750</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;Apologies for off topic comment. I just recalled &lt;STRONG&gt;your&lt;/STRONG&gt; extended and selfless help in teaching me sas macros functions on SAS-L couple of years ago over many iterations :). That was priceless. I'm afraid I didn't thank you enough back then but at least I could do now. Cheers!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This line of yours gave me the reminiscence of that thread on SAS-L 2 years ago:)&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 19:45:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-separate-id-for-same-value-of-a-variable/m-p/402489#M97750</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-10-09T19:45:26Z</dc:date>
    </item>
  </channel>
</rss>

