<?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: How to combine dif variable and create new variable with different variable value separate by co in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657687#M197126</link>
    <description>&lt;P&gt;Just to be consistent about asking, what will you be able to do the combined drug variable that you cannot do with the data in current form?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Almost any any analysis is going to be much harder with multiple values in a single variable.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jun 2020 22:15:06 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-06-11T22:15:06Z</dc:date>
    <item>
      <title>How to combine dif variable and create new variable with different variable value separate by coma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657676#M197119</link>
      <description>&lt;P&gt;Hi I have data look like this.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dpa_0-1591909675155.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/42728iDB0EC9575181F18A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dpa_0-1591909675155.png" alt="dpa_0-1591909675155.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want like this.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dpa_1-1591909806319.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/42729i5BF5F988E8E485BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dpa_1-1591909806319.png" alt="dpa_1-1591909806319.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;so basically want to combine drug in one variable for each unique id and seq.&lt;/P&gt;&lt;P&gt;Any pointer please ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 21:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657676#M197119</guid>
      <dc:creator>dpa</dc:creator>
      <dc:date>2020-06-11T21:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657678#M197121</link>
      <description>data have;&lt;BR /&gt;input id seq drug $;&lt;BR /&gt;cards;&lt;BR /&gt;1 1 a&lt;BR /&gt;1 1 b&lt;BR /&gt;2 1 d&lt;BR /&gt;3 1 b&lt;BR /&gt;3 1 c&lt;BR /&gt;3 1 d&lt;BR /&gt;3 2 e&lt;BR /&gt;4 1 a&lt;BR /&gt;4 2 h&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt; do until(last.seq);&lt;BR /&gt;  set have;&lt;BR /&gt;  by id seq;&lt;BR /&gt;  length _drug $100;&lt;BR /&gt;  _drug=catx(',',_drug,drug);&lt;BR /&gt; end;&lt;BR /&gt; rename _drug=drug;&lt;BR /&gt; drop drug;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Jun 2020 21:28:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657678#M197121</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-11T21:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657680#M197122</link>
      <description>Perhaps this is easier to understand-&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data have;&lt;BR /&gt;input id seq drug $;&lt;BR /&gt;cards;&lt;BR /&gt;1 1 a&lt;BR /&gt;1 1 b&lt;BR /&gt;2 1 d&lt;BR /&gt;3 1 b&lt;BR /&gt;3 1 c&lt;BR /&gt;3 1 d&lt;BR /&gt;3 2 e&lt;BR /&gt;4 1 a&lt;BR /&gt;4 2 h&lt;BR /&gt;;&lt;BR /&gt;proc transpose data=have out=temp;&lt;BR /&gt;by id seq;&lt;BR /&gt;var drug;&lt;BR /&gt;run;&lt;BR /&gt;data want;&lt;BR /&gt; set temp;&lt;BR /&gt; drug=catx(',',of col:);&lt;BR /&gt; keep id seq drug;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Jun 2020 21:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657680#M197122</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-11T21:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657681#M197123</link>
      <description>&lt;P&gt;Something like below should do. Data "have" must be sorted by ID and SEQ.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by id seq;
  length drug_list $1000;
  drug_list=catx(',',drug_list,drug);
  if last.seq then 
    do;
      output;
      call missing(drug_list);
    end;
  drop drug;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 00:03:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657681#M197123</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-13T00:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657687#M197126</link>
      <description>&lt;P&gt;Just to be consistent about asking, what will you be able to do the combined drug variable that you cannot do with the data in current form?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Almost any any analysis is going to be much harder with multiple values in a single variable.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 22:15:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657687#M197126</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-11T22:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657690#M197128</link>
      <description>HI Tried to transpose but the only issue to concatenation as after transposing i have so many different variable name for all drugs so can i do that?</description>
      <pubDate>Thu, 11 Jun 2020 22:32:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657690#M197128</guid>
      <dc:creator>dpa</dc:creator>
      <dc:date>2020-06-11T22:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657691#M197129</link>
      <description>sorry thanks but didn't work</description>
      <pubDate>Thu, 11 Jun 2020 22:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657691#M197129</guid>
      <dc:creator>dpa</dc:creator>
      <dc:date>2020-06-11T22:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657692#M197130</link>
      <description>it's for listing</description>
      <pubDate>Thu, 11 Jun 2020 22:33:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657692#M197130</guid>
      <dc:creator>dpa</dc:creator>
      <dc:date>2020-06-11T22:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657694#M197132</link>
      <description>Thank you it worked but please can you explain logic behind that.</description>
      <pubDate>Thu, 11 Jun 2020 22:39:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657694#M197132</guid>
      <dc:creator>dpa</dc:creator>
      <dc:date>2020-06-11T22:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657711#M197143</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/99341"&gt;@dpa&lt;/a&gt;&amp;nbsp; Sure. The logic is pretty straight forward technique that does row-wise concatentation for each &lt;STRONG&gt;&lt;EM&gt;by group.&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;In your case each by-group is a unique combination of &lt;EM&gt;&lt;STRONG&gt;Id Seq.&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;Now at this point you'd have already guessed the &lt;STRONG&gt;&lt;EM&gt;do until(last.seq)&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;continues to process/execute up until all the records of each by group is read and processed. The concatentation takes place for each record and every record of a by group for the variable drug and finallyy&amp;nbsp;written to the output dataset once the processing is complete. The same is repeated for every such By-group until all records in the input dataset are read and processed. Hope this helps?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 11:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657711#M197143</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-12T11:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657922#M197168</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/99341"&gt;@dpa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;sorry thanks but didn't work&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just for the future: It helps all of us if you let us know WHAT didn't work - like some description and/or post the relevant log section which shows the issue.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 06:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/657922#M197168</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-12T06:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/658057#M197209</link>
      <description>that's good point. So it didn't give me error but new variable didn't come with drug separated with comma it came as previous drug values. hope that helps.</description>
      <pubDate>Fri, 12 Jun 2020 13:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/658057#M197209</guid>
      <dc:creator>dpa</dc:creator>
      <dc:date>2020-06-12T13:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/658059#M197211</link>
      <description>Got it now. Thanks</description>
      <pubDate>Fri, 12 Jun 2020 13:22:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/658059#M197211</guid>
      <dc:creator>dpa</dc:creator>
      <dc:date>2020-06-12T13:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine dif variable and create new variable with different variable value separate by co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/658227#M197272</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/99341"&gt;@dpa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Forgot to add a Retain statement so variable drug_list doesn't get re-initialized for every iteration of the data step. Below code that should be o.k.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by id seq;
  length drug_list $1000;
  retain drug_list;
  drug_list=catx(',',drug_list,drug);
  if last.seq then 
    do;
      output;
      call missing(drug_list);
    end;
  drop drug;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Jun 2020 00:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-dif-variable-and-create-new-variable-with/m-p/658227#M197272</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-13T00:05:34Z</dc:date>
    </item>
  </channel>
</rss>

