<?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: Columns are missing while merging in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155017#M2689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="255172" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; pointed already out that you need a "by" statement for your merge and I totally agree with &lt;A __default_attr="119192" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; that having a long instead of a wide data structure is very often beneficial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Under the assumption that your Action1 to Action40 variables are populated starting with Action1 and that once there is a missing all later Action variables are also missing, then one could simply count the number of non-missing variables. That's what's done in below code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have(drop=_i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; length rowid 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array action {40} 8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do rowid=1 to 20;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do _i=1 to dim(action);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; action[_i]=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ceil(ranuni(1)*40)=20 then leave;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call missing(of action&lt;LI&gt;);&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length rowid action_count 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array action {*} action1-action40;&lt;/P&gt;&lt;P&gt;&amp;nbsp; action_count=n(of action&lt;LI&gt;);&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 08 Nov 2014 23:53:15 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2014-11-08T23:53:15Z</dc:date>
    <item>
      <title>Columns are missing while merging</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155006#M2678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've two tables which needs to be merged. While doing so, I'm being left with only few columns in the resultant table.&lt;/P&gt;&lt;P&gt;Why so....?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data logfile_final_UI7;&lt;/P&gt;&lt;P&gt;merge logfile_new new_parse;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 20:10:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155006#M2678</guid>
      <dc:creator>NareshAbburi</dc:creator>
      <dc:date>2014-11-03T20:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Columns are missing while merging</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155007#M2679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about some details such as:&lt;/P&gt;&lt;P&gt;Variables in logfile_new&lt;/P&gt;&lt;P&gt;Variable in new_parse&lt;/P&gt;&lt;P&gt;And the missing columns.&lt;/P&gt;&lt;P&gt;A few rows of data from each file and the result would also be helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 20:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155007#M2679</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-11-03T20:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Columns are missing while merging</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155008#M2680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;Please find the attached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="file1.PNG" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/7801_file1.PNG" width="450" /&gt;&lt;IMG alt="file2.PNG" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/7802_file2.PNG" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 20:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155008#M2680</guid>
      <dc:creator>NareshAbburi</dc:creator>
      <dc:date>2014-11-03T20:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Columns are missing while merging</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155009#M2681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG alt="query.PNG" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/7803_query.PNG" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 20:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155009#M2681</guid>
      <dc:creator>NareshAbburi</dc:creator>
      <dc:date>2014-11-03T20:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: Columns are missing while merging</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155010#M2682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You haven't said which column is missing or provided an example of the actual output.&lt;/P&gt;&lt;P&gt;And the second set of code references two different data sets.&lt;/P&gt;&lt;P&gt;Do the two datasets have the same number of rows? Without a by&amp;nbsp; statement to line things up then you may be getting missing results because of the numbers of rows not matching.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And instead of that many If then else statements:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array a Action1-action40;&lt;/P&gt;&lt;P&gt;action_count=0;&lt;/P&gt;&lt;P&gt;do j = dim(a) to 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if a&lt;J&gt; ne ' ' then action_count=j;&lt;/J&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if action_count &amp;gt; 0 then leave;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 20:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155010#M2682</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-11-03T20:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Columns are missing while merging</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155011#M2683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;this is the output table. your answer helped to make an array instead of big query.&lt;/P&gt;&lt;P&gt;but the missing column is FILEID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="output.PNG" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/7804_output.PNG" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 20:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155011#M2683</guid>
      <dc:creator>NareshAbburi</dc:creator>
      <dc:date>2014-11-03T20:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: Columns are missing while merging</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155012#M2684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code looks incorrect. I would expect a merge to have a BY statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data logfile_final_UI7;&lt;/P&gt;&lt;P&gt;merge logfile_new new_parse;&lt;/P&gt;&lt;P&gt;BY fileid;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****other sas code here***;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 21:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155012#M2684</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-11-03T21:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: Columns are missing while merging</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155013#M2685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Run proc contents on the two input files and the result files and post that information. Screen shots of data sets aren't that helpful as they don't show all of the columns.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 21:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155013#M2685</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-11-03T21:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Columns are missing while merging</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155014#M2686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I haven't dug into you problem, but your code clearly shouts: Transpose My Data Set!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 18:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155014#M2686</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-11-05T18:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Columns are missing while merging</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155015#M2687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What needs to be done if I need to create a new variable based on looping?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; if a&lt;J&gt; ne ' ' then action_count&lt;STRONG&gt;&lt;J&gt;&lt;/J&gt;&lt;/STRONG&gt;=j;&lt;/J&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2014 13:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155015#M2687</guid>
      <dc:creator>RamKumar</dc:creator>
      <dc:date>2014-11-06T13:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: Columns are missing while merging</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155016#M2688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;any suggestions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Nov 2014 16:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155016#M2688</guid>
      <dc:creator>RamKumar</dc:creator>
      <dc:date>2014-11-08T16:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Columns are missing while merging</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155017#M2689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="255172" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; pointed already out that you need a "by" statement for your merge and I totally agree with &lt;A __default_attr="119192" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; that having a long instead of a wide data structure is very often beneficial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Under the assumption that your Action1 to Action40 variables are populated starting with Action1 and that once there is a missing all later Action variables are also missing, then one could simply count the number of non-missing variables. That's what's done in below code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have(drop=_i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; length rowid 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array action {40} 8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do rowid=1 to 20;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do _i=1 to dim(action);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; action[_i]=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ceil(ranuni(1)*40)=20 then leave;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call missing(of action&lt;LI&gt;);&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length rowid action_count 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array action {*} action1-action40;&lt;/P&gt;&lt;P&gt;&amp;nbsp; action_count=n(of action&lt;LI&gt;);&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Nov 2014 23:53:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Columns-are-missing-while-merging/m-p/155017#M2689</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-11-08T23:53:15Z</dc:date>
    </item>
  </channel>
</rss>

