<?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: Collapse partial dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516553#M3191</link>
    <description>&lt;P&gt;Thanks! I want to keep H5, H3 and H2 also&lt;/P&gt;</description>
    <pubDate>Wed, 28 Nov 2018 03:39:37 GMT</pubDate>
    <dc:creator>Dunne</dc:creator>
    <dc:date>2018-11-28T03:39:37Z</dc:date>
    <item>
      <title>Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516542#M3186</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset like below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; Date&amp;nbsp; &amp;nbsp; Dx1&amp;nbsp; &amp;nbsp;Dx2&amp;nbsp; &amp;nbsp; Dx3&amp;nbsp; &amp;nbsp;Dx4&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;100&amp;nbsp; &amp;nbsp; &amp;nbsp; H1&amp;nbsp; &amp;nbsp; &amp;nbsp;H2&amp;nbsp; &amp;nbsp; &amp;nbsp; H3&amp;nbsp; &amp;nbsp; &amp;nbsp;H4&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;100&amp;nbsp; &amp;nbsp; &amp;nbsp; H3&amp;nbsp; &amp;nbsp; &amp;nbsp;H2&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;100&amp;nbsp; &amp;nbsp; &amp;nbsp; H5&amp;nbsp; &amp;nbsp; &amp;nbsp;H1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp; H5&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp; H3&amp;nbsp; &amp;nbsp; H2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to remove the partial duplicate data. If ID and Date are the same, then keep all the values of Dx1-Dx4 but just in 1 row only. My scenario is more likely like the ID 1 person in the first 3 rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The final data set look like below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; Date&amp;nbsp; &amp;nbsp; Dx1&amp;nbsp; &amp;nbsp;Dx2&amp;nbsp; &amp;nbsp; Dx3&amp;nbsp; &amp;nbsp;Dx4&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;100&amp;nbsp; &amp;nbsp; &amp;nbsp; H1&amp;nbsp; &amp;nbsp; &amp;nbsp;H2&amp;nbsp; &amp;nbsp; &amp;nbsp; H3&amp;nbsp; &amp;nbsp; &amp;nbsp;H4&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp; H5&amp;nbsp; &amp;nbsp; &amp;nbsp;H3&amp;nbsp; &amp;nbsp; &amp;nbsp; H2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 01:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516542#M3186</guid>
      <dc:creator>Dunne</dc:creator>
      <dc:date>2018-11-28T01:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516546#M3187</link>
      <description>&lt;P&gt;Can you clarify my assumption&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp; H5&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp; H3&amp;nbsp; &amp;nbsp; H2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;does the first obs on the by group as in the example H5 will occupy Dx1 replacing H3 and displacing H3 to Dx2?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 02:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516546#M3187</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-28T02:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516547#M3188</link>
      <description>&lt;P&gt;why 1 500 H5 lost？&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  temp;
	set a;
	array array_a Dx1-Dx4;
	length newVal $2;
	do over array_a;
		if array_a^='' then do;
			newVal=array_a;
			output;
		end;
	end;
	drop Dx1-Dx4;
run;
proc sort data=temp nodupkey;
	by id date newVal;
run;
proc transpose data=temp out=result(drop=_name_) prefix=Dx;
	by id date;
	var newVal;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Nov 2018 02:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516547#M3188</guid>
      <dc:creator>learsaas</dc:creator>
      <dc:date>2018-11-28T02:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516551#M3189</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/192107"&gt;@learsaas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;why 1 500 H5 lost？&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  temp;
	set a;
	array array_a Dx1-Dx4;
	length newVal $2;
	do over array_a;
		if array_a^='' then do;
			newVal=array_a;
			output;
		end;
	end;
	drop Dx1-Dx4;
run;
proc sort data=temp nodupkey;
	by id date newVal;
run;
proc transpose data=temp out=result(drop=_name_) prefix=Dx;
	by id date;
	var newVal;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A tranpose to long and then flip to wide after removing duplicates is a great&amp;nbsp;solution. Only modification I'd consider to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/192107"&gt;@learsaas&lt;/a&gt;&amp;nbsp;excellent solution, is to replace DO OVER since it's deprecated for an explicit loop. Otherwise it will handle all various situations such as multiple lines and duplicate codes as shown in your example.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 03:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516551#M3189</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-28T03:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516553#M3191</link>
      <description>&lt;P&gt;Thanks! I want to keep H5, H3 and H2 also&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 03:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516553#M3191</guid>
      <dc:creator>Dunne</dc:creator>
      <dc:date>2018-11-28T03:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516554#M3192</link>
      <description>&lt;P&gt;Thank you! I want to keep H5 also. Sorry for the confusion!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 03:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516554#M3192</guid>
      <dc:creator>Dunne</dc:creator>
      <dc:date>2018-11-28T03:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516575#M3198</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
input ID  Date    (Dx1   Dx2    Dx3   Dx4 ) ($);
cards;
1   100      H1     H2      H3     H4
1   100      H3     H2
1   100      H5     H1
1   200      H5
1   200      H3    H2
;

data _null_;
if _n_=1 then do;
 declare hash H (ordered: "A") ;
   h.definekey  ("id","date","dx") ;
   h.definedone () ;
end;
set have end=lr;
by id date; 
array t(*) dx1-dx4;
do _n_=1 to dim(t);
if not missing(t(_n_))  then do;
dx=t(_n_);
rc=h.add();
end;
end;
if lr then h.output(dataset:'w');
run;

proc transpose data=w out=want(drop=_:) prefix=Dx;
by id date;
var dx;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Nov 2018 05:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516575#M3198</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-28T05:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516884#M3244</link>
      <description>&lt;P&gt;Reeza, how would you change the code to replace&amp;nbsp;&lt;SPAN&gt;DO OVER? I didn't understand the part about it being deprecated for an explicit loop&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 21:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516884#M3244</guid>
      <dc:creator>janus58</dc:creator>
      <dc:date>2018-11-28T21:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516900#M3247</link>
      <description>Do Over is deprecated - SAS 7 I believe, so more than 20 years ago. There’s a do loop in novinsrin answer that is close. Note the explicit I index usd, ie t( index ) rather than just t used. Explicit arrays make it clear when an array is being used compared to do over which is referenced similar to a variable. That confusion alone is why it’s a good reason to switch to explicit arrays that must be referenced via the index.</description>
      <pubDate>Wed, 28 Nov 2018 22:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516900#M3247</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-28T22:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516902#M3248</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71096"&gt;@janus58&lt;/a&gt;&amp;nbsp; Take a look at this thread and Soren Lassen's reponse&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/what-s-the-limit-to-how-many-elements-variables-a-SAS-array-can/m-p/499675/highlight/true#M132992" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/what-s-the-limit-to-how-many-elements-variables-a-SAS-array-can/m-p/499675/highlight/true#M132992&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-04 lia-quilt-column-left lia-quilt-column-main-left"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;
&lt;DIV class="lia-message-author lia-component-author"&gt;
&lt;DIV class="lia-message-author-username"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-PROC-Star"&gt;&lt;IMG class="lia-user-rank-icon lia-user-rank-icon-left" src="https://communities.sas.com/html/rank_icons/proc-star-rank.png" border="0" alt="PROC Star" title="PROC Star" /&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A id="link_43" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464" target="_self"&gt;&lt;SPAN class="login-bold"&gt;s_lassen&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="lia-message-author-rank"&gt;PROC Star&lt;/DIV&gt;
&lt;DIV class="lia-message-author-avatar"&gt;
&lt;DIV class="UserAvatar lia-user-avatar lia-component-common-widget-user-avatar"&gt;&lt;A id="link_44" class="UserAvatar lia-link-navigation" tabindex="-1" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464" target="_self"&gt;&lt;IMG class="lia-user-avatar-message" src="https://communities.sas.com/t5/image/serverpage/avatar-name/bike/avatar-theme/candy/avatar-collection/transit/avatar-display-size/message?xdesc=1.0" border="0" alt="s_lassen" title="s_lassen" /&gt;&lt;/A&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="lia-message-author-post-count"&gt;Posts: 375&lt;/DIV&gt;
&lt;DIV class="lia-message-author-ipaddress"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-right lia-quilt-column-main-right"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;
&lt;DIV class="lia-message-heading lia-component-message-header"&gt;
&lt;DIV class="lia-quilt-row lia-quilt-row-standard"&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-left"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;
&lt;DIV class="lia-message-subject"&gt;
&lt;H2&gt;Re: what's the limit to how many elements(variables) a SAS array can hold?&lt;/H2&gt;
&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;
&lt;DIV&gt;
&lt;DIV class="MessageReadByModeratorCell lia-moderation-moderated"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-04 lia-quilt-column-right"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;
&lt;DIV class="lia-message-options"&gt;
&lt;DIV id="actionMenuDropDown_7" class="lia-menu-navigation-wrapper lia-menu-action message-menu"&gt;
&lt;DIV class="lia-menu-navigation"&gt;
&lt;DIV class="dropdown-default-item"&gt;&lt;A id="dropDownLink_7" class="lia-js-menu-opener default-menu-option lia-js-click-menu lia-link-navigation" title="Show option menu" href="https://communities.sas.com/t5/SAS-Programming/what-s-the-limit-to-how-many-elements-variables-a-SAS-array-can/m-p/499675/highlight/true#" target="_blank"&gt;Options&lt;/A&gt;
&lt;DIV class="dropdown-positioning"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="reply-to-stamp"&gt;&lt;SPAN class="reply-author"&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/what-s-the-limit-to-how-many-elements-variables-a-SAS-array-can/m-p/499675#M132992" target="_blank"&gt;Posted in reply to&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;novinosrin&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;P class="lia-message-dates lia-message-post-date lia-component-post-date-last-edited"&gt;&lt;SPAN class="DateTime lia-message-posted-on lia-component-common-widget-date"&gt;&lt;SPAN class="local-date"&gt;‎09-28-2018&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="local-time"&gt;05:19 AM&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV id="messagebodydisplay_0_6" class="lia-message-body lia-component-body"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Implicit array references (do over) are not encouraged, because SAS Institute intends to do away with them (it has been an undocumented feature for years, now). So if you use them, you risk that your program will have to be rewritten when the next version of SAS comes out. &lt;STRONG&gt;Performance-wise, DO OVER is just the same as explicit array processing (&lt;/STRONG&gt;a temporary variable named _I_ is created in the background and used to loop through the array).&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 28 Nov 2018 23:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516902#M3248</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-28T23:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516914#M3252</link>
      <description>&lt;P&gt;thanks a lot for the explanation&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 23:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516914#M3252</guid>
      <dc:creator>janus58</dc:creator>
      <dc:date>2018-11-28T23:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516916#M3253</link>
      <description>&lt;P&gt;You're welcome. Actually we should rather thank&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;for the prompt and wise correction. I'm glad for your question. Have a good one!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 23:48:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516916#M3253</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-28T23:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse partial dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516929#M3256</link>
      <description>&lt;P&gt;ID&amp;nbsp; Date&amp;nbsp; &amp;nbsp; Dx1&amp;nbsp; &amp;nbsp;Dx2&amp;nbsp; &amp;nbsp; Dx3&amp;nbsp; &amp;nbsp;Dx4&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;100&amp;nbsp; &amp;nbsp; &amp;nbsp; H1&amp;nbsp; &amp;nbsp; &amp;nbsp;H2&amp;nbsp; &amp;nbsp; &amp;nbsp; H3&amp;nbsp; &amp;nbsp; &amp;nbsp;H4&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp; A9&amp;nbsp; &amp;nbsp; &amp;nbsp;H3&amp;nbsp; &amp;nbsp; &amp;nbsp; H2&amp;nbsp; &amp;nbsp; &amp;nbsp;A1&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp;340&amp;nbsp; &amp;nbsp; &amp;nbsp; B2&amp;nbsp; &amp;nbsp; &amp;nbsp;C1&amp;nbsp; &amp;nbsp; &amp;nbsp; H1&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp;250&amp;nbsp; &amp;nbsp; &amp;nbsp; X1&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp;350&amp;nbsp; &amp;nbsp; &amp;nbsp; Y1&amp;nbsp; &amp;nbsp; &amp;nbsp;C1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My result now looks like this. But I get stuck with the next step. I want to find if any Dx1-Dx4 has &amp;nbsp;H* values, if there is any then create variable dx= value of the first Dx* which have H* appear (ex:id=2 the dx=value of dx2=H3) if not then take other value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The result desires to look like this&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; Date&amp;nbsp; &amp;nbsp; Dx&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;100&amp;nbsp; &amp;nbsp; &amp;nbsp; H1&amp;nbsp;&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp; H3&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp;340&amp;nbsp; &amp;nbsp; &amp;nbsp; H1&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp;250&amp;nbsp; &amp;nbsp; &amp;nbsp; X1&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp;Y1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Additionally I want to make a table (with one column) with all unique characters which are different from H*&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks!!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 01:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Collapse-partial-dataset/m-p/516929#M3256</guid>
      <dc:creator>Dunne</dc:creator>
      <dc:date>2018-11-29T01:46:13Z</dc:date>
    </item>
  </channel>
</rss>

