<?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 Need the correct output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833503#M329495</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I have input like this, Where information for particular id is segregated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;input &lt;BR /&gt;id&amp;nbsp; &amp;nbsp;name&amp;nbsp; &amp;nbsp;lastname&amp;nbsp; number &lt;BR /&gt;1&amp;nbsp; John&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;.&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Deo&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp;&lt;BR /&gt;1&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;8888&lt;/P&gt;
&lt;P&gt;I need Output&amp;nbsp; like this , where for a particular id , all information should come in single row.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;id&amp;nbsp; name&amp;nbsp; lastname&amp;nbsp; &amp;nbsp;number&lt;BR /&gt;1&amp;nbsp; John&amp;nbsp; &amp;nbsp; Deo&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8888&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me&amp;nbsp; in solving this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 15 Sep 2022 06:43:06 GMT</pubDate>
    <dc:creator>Aexor</dc:creator>
    <dc:date>2022-09-15T06:43:06Z</dc:date>
    <item>
      <title>Need the correct output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833503#M329495</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I have input like this, Where information for particular id is segregated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;input &lt;BR /&gt;id&amp;nbsp; &amp;nbsp;name&amp;nbsp; &amp;nbsp;lastname&amp;nbsp; number &lt;BR /&gt;1&amp;nbsp; John&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;.&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Deo&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp;&lt;BR /&gt;1&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;8888&lt;/P&gt;
&lt;P&gt;I need Output&amp;nbsp; like this , where for a particular id , all information should come in single row.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;id&amp;nbsp; name&amp;nbsp; lastname&amp;nbsp; &amp;nbsp;number&lt;BR /&gt;1&amp;nbsp; John&amp;nbsp; &amp;nbsp; Deo&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8888&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me&amp;nbsp; in solving this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 06:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833503#M329495</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2022-09-15T06:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need the correct output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833504#M329496</link>
      <description>&lt;P&gt;Do you have more variables than 3 in your actual data?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 06:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833504#M329496</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-15T06:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need the correct output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833505#M329497</link>
      <description>&lt;P&gt;See if this works for you. I added an extra ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id name $ lastname $ number;
infile datalines dlm = '|';
datalines;
1|John|   |.    
1|    |Deo|.    
1|    |   |8888 
2|John|   |.    
2|    |Deo|.    
2|    |   |8888 
;

data want;
   update have(obs = 0) have;
   by id;
   if last.ID then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Sep 2022 06:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833505#M329497</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-15T06:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need the correct output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833506#M329498</link>
      <description>Yes, posted these as sample only</description>
      <pubDate>Thu, 15 Sep 2022 06:51:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833506#M329498</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2022-09-15T06:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need the correct output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833507#M329499</link>
      <description>&lt;P&gt;Ok. Does my code below work for you?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 06:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833507#M329499</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-15T06:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need the correct output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833508#M329500</link>
      <description>let me check &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I will id more ids with different combination and try</description>
      <pubDate>Thu, 15 Sep 2022 07:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833508#M329500</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2022-09-15T07:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need the correct output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833540#M329518</link>
      <description>Thanks. This code worked. Just a small request . Could you please explain how this update statement worked</description>
      <pubDate>Thu, 15 Sep 2022 09:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833540#M329518</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2022-09-15T09:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need the correct output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833541#M329519</link>
      <description>&lt;P&gt;Sure. This is a weel known technique among SAS programmers to replace missing obs with previous non-missing values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The key to this trick is the UPDATE Statement. I use have(obs=0) as the master data set to load the relevant variables and no observations into the PDV. Next, I also use have(all observations included) as the transaction data set and update the master data set from this. Also, I have to use an explicit OUTPUT Statement, because by default SAS only updates the first observation in each group and outputs that.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;As per the &lt;A href="https://documentation.sas.com/doc/da/pgmsascdc/9.4_3.5/lestmtsref/p18w3br45er2qun1r8sfmm4grjyr.htm" target="_self"&gt;Update Statemnet Doc&lt;/A&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;By default, the UPDATEMODE=MISSINGCHECK option is in effect, so missing values in the transaction data set do&amp;nbsp;not&amp;nbsp;replace existing values in the master data set. If you want missing values in the transaction data set to replace existing values in the master data set, specify the UPDATEMODE=NOMISSINGCHECK option in the UPDATE statement.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 09:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833541#M329519</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-15T09:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need the correct output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833543#M329520</link>
      <description>Thanks a ton!!!!!!!!!!!!</description>
      <pubDate>Thu, 15 Sep 2022 09:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833543#M329520</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2022-09-15T09:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need the correct output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833544#M329521</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327170"&gt;@Aexor&lt;/a&gt;&amp;nbsp; Anytime &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;Please remember to mark my answer as accepted solution.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 09:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833544#M329521</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-15T09:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need the correct output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833549#M329523</link>
      <description>Yes. Done that. Just one more information .&lt;BR /&gt;&lt;BR /&gt;I have used this code and this also worked fine&lt;BR /&gt;data have;&lt;BR /&gt;input id name $ lastname $ number;&lt;BR /&gt;infile datalines dlm = '|';&lt;BR /&gt;datalines;&lt;BR /&gt;1|John|   |.    &lt;BR /&gt;1|    |Deo|.    &lt;BR /&gt;1|    |   |8888 &lt;BR /&gt;2|John|   |.    &lt;BR /&gt;2|    |Deo|.    &lt;BR /&gt;2|    |   |8888&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;   update have(obs=0)  have;&lt;BR /&gt;   by id;&lt;BR /&gt;/*    if last.ID then output; */&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Could you please tell me significance of last.id in your code.</description>
      <pubDate>Thu, 15 Sep 2022 10:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-the-correct-output/m-p/833549#M329523</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2022-09-15T10:20:36Z</dc:date>
    </item>
  </channel>
</rss>

