<?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 make combine different observations in relation to a variable to make a new combo variabl in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840708#M332415</link>
    <description>This is the code used:&lt;BR /&gt;DATA drugs;&lt;BR /&gt;     Input Patient_ID  Drug_ID Drug :$20;&lt;BR /&gt;          &lt;BR /&gt;Datalines;&lt;BR /&gt;&lt;BR /&gt;9900001 1 vinorelbine&lt;BR /&gt;9900001 2 carboplatin&lt;BR /&gt;9900001 2 paclitaxel&lt;BR /&gt;9900003 1 fluorouracil&lt;BR /&gt;9900005 1 5-FU&lt;BR /&gt;9900005 1 leucovorin&lt;BR /&gt;9900005 2 fluorouracil&lt;BR /&gt;9900005 3 fluorouracil&lt;BR /&gt;9900005 3 leucovorin&lt;BR /&gt;9900008 1 fluorouracil&lt;BR /&gt;9900008 2 fluorouracil&lt;BR /&gt;9900008 2 leucovorin&lt;BR /&gt;9900008 3 fluorouracil&lt;BR /&gt;9900008 3 irinotecan&lt;BR /&gt;9900008 3 leucovorin&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;Data Drug_combo (DROP=drug);&lt;BR /&gt;     DO until (last.drug_ID);&lt;BR /&gt;     SET drugs;&lt;BR /&gt;     BY Patient_ID Drug_ID;&lt;BR /&gt;     LENGTH drug_combo $200;&lt;BR /&gt;     drug_combo= catx('', drug_combo, drug);&lt;BR /&gt;    end;&lt;BR /&gt; RUN;&lt;BR /&gt;    &lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;My log:&lt;BR /&gt; &lt;BR /&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 68         &lt;BR /&gt; 69         DATA drugs;&lt;BR /&gt; 70              Input Patient_ID  Drug_ID Drug :$20;&lt;BR /&gt; 71         &lt;BR /&gt; 72         Datalines;&lt;BR /&gt; &lt;BR /&gt; NOTE: SAS went to a new line when INPUT statement reached past the end of a line.&lt;BR /&gt; NOTE: The data set WORK.DRUGS has 14 observations and 3 variables.&lt;BR /&gt; NOTE: DATA statement used (Total process time):&lt;BR /&gt;       real time           0.00 seconds&lt;BR /&gt;       user cpu time       0.00 seconds&lt;BR /&gt;       system cpu time     0.00 seconds&lt;BR /&gt;       memory              669.78k&lt;BR /&gt;       OS Memory           23976.00k&lt;BR /&gt;       Timestamp           10/25/2022 10:23:33 PM&lt;BR /&gt;       Step Count                        24  Switch Count  2&lt;BR /&gt;       Page Faults                       0&lt;BR /&gt;       Page Reclaims                     167&lt;BR /&gt;       Page Swaps                        0&lt;BR /&gt;       Voluntary Context Switches        13&lt;BR /&gt;       Involuntary Context Switches      0&lt;BR /&gt;       Block Input Operations            0&lt;BR /&gt;       Block Output Operations           264&lt;BR /&gt;       &lt;BR /&gt; &lt;BR /&gt; 89         ;&lt;BR /&gt; 90         &lt;BR /&gt; 91         RUN;&lt;BR /&gt; 92         &lt;BR /&gt; 93         Data Drug_combo (DROP=drug);&lt;BR /&gt; 94              DO until (last.drug_ID);&lt;BR /&gt; 95              SET drugs;&lt;BR /&gt; 96              BY Patient_ID Drug_ID;&lt;BR /&gt; 97              LENGTH drug_combo $200;&lt;BR /&gt; 98              drug_combo= catx('', drug_combo, drug);&lt;BR /&gt; 99             end;&lt;BR /&gt; 100         RUN;&lt;BR /&gt; &lt;BR /&gt; NOTE: There were 14 observations read from the data set WORK.DRUGS.&lt;BR /&gt; NOTE: The data set WORK.DRUG_COMBO has 9 observations and 3 variables.&lt;BR /&gt; NOTE: DATA statement used (Total process time):&lt;BR /&gt;       real time           0.00 seconds&lt;BR /&gt;       user cpu time       0.01 seconds&lt;BR /&gt;       system cpu time     0.00 seconds&lt;BR /&gt;       memory              1070.75k&lt;BR /&gt;       OS Memory           24236.00k&lt;BR /&gt;       Timestamp           10/25/2022 10:23:33 PM&lt;BR /&gt;       Step Count                        25  Switch Count  2&lt;BR /&gt;       Page Faults                       0&lt;BR /&gt;       Page Reclaims                     210&lt;BR /&gt;       Page Swaps                        0&lt;BR /&gt;       Voluntary Context Switches        13&lt;BR /&gt;       Involuntary Context Switches      0&lt;BR /&gt;       Block Input Operations            0&lt;BR /&gt;       Block Output Operations           264&lt;BR /&gt;       &lt;BR /&gt; &lt;BR /&gt; 101        &lt;BR /&gt; 102        &lt;BR /&gt; 103        &lt;BR /&gt; 104        &lt;BR /&gt; 105        &lt;BR /&gt; 106        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 116        &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My output:&lt;BR /&gt;&lt;BR /&gt;Obs Patient_ID Drug_ID Drug&lt;BR /&gt;1 9900008 3 c&lt;BR /&gt;2 9900008 2 c&lt;BR /&gt;3 9900008 2 n&lt;BR /&gt;4 9900008 1 c&lt;BR /&gt;5 9900008 3 n&lt;BR /&gt;6 9900008 3 n&lt;BR /&gt;7 9900005 3 c&lt;BR /&gt;8 9900005 2 c&lt;BR /&gt;9 9900005 1 9&lt;BR /&gt;10 9900005 3 n&lt;BR /&gt;11 9900003 1 c&lt;BR /&gt;12 9900001 2 l&lt;BR /&gt;13 9900001 1 n&lt;BR /&gt;14 9900001 2 i</description>
    <pubDate>Tue, 25 Oct 2022 22:25:06 GMT</pubDate>
    <dc:creator>mcalde33</dc:creator>
    <dc:date>2022-10-25T22:25:06Z</dc:date>
    <item>
      <title>how to make combine different observations in relation to a variable to make a new combo variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840650#M332387</link>
      <description>&lt;P&gt;I need to make table A into Table B:&lt;/P&gt;&lt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&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;fluorouracil&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;9900008&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;fluorouracil leucovorin&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;9900008&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;fluorouracil irinotecan leucovorin&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 18:22:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840650#M332387</guid>
      <dc:creator>mcalde33</dc:creator>
      <dc:date>2022-10-25T18:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to make combine different observations in relation to a variable to make a new combo variabl</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840653#M332389</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Patient_ID $ drug_ID drug :$20.;
datalines;
9900001 1 vinorelbine  
9900001 2 carboplatin  
9900001 2 paclitaxel   
9900003 1 fluorouracil 
9900005 1 5-FU         
9900005 1 leucovorin   
9900005 2 fluorouracil 
9900005 3 fluorouracil 
9900005 3 leucovorin   
9900008 1 fluorouracil 
9900008 2 fluorouracil 
9900008 2 leucovorin   
9900008 3 fluorouracil 
9900008 3 irinotecan   
9900008 3 leucovorin   
;

data want(drop = drug);
   do until (last.drug_ID);
      set have;
      by Patient_ID drug_ID;
      length drug_combo $200;
      drug_combo = catx(' ', drug_combo, drug);
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Result:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Patient_ID  drug_ID  drug_combo
9900001     1        vinorelbine
9900001     2        carboplatin paclitaxel
9900003     1        fluorouracil
9900005     1        5-FU leucovorin
9900005     2        fluorouracil
9900005     3        fluorouracil leucovorin
9900008     1        fluorouracil
9900008     2        fluorouracil leucovorin
9900008     3        fluorouracil irinotecan leucovorin&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Oct 2022 18:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840653#M332389</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-10-25T18:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to make combine different observations in relation to a variable to make a new combo variabl</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840667#M332398</link>
      <description>&lt;P&gt;What exactly is superior about Table B?&lt;/P&gt;
&lt;P&gt;Do you expect the result to always be fluorouracil leucovorin, to pick one combination, when the order in the original data might result in leucovorin fluorouracil from different sequences of data?&lt;/P&gt;
&lt;P&gt;Do you have any idea what the maximum number of items might need to be combined? This goes to setting the maximum length of the target variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suggestion: If you must combine such place a character between values that will not appear in your values so that it is possible to separate them back to the originals later when it is needed (and likely will be needed). Very easy to do with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;'s code. Place a comma, for example in the CATX function call: Catx(',' ,&amp;lt;other parameters&amp;gt;) for example places a comma between all the values.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 20:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840667#M332398</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-25T20:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to make combine different observations in relation to a variable to make a new combo variabl</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840673#M332400</link>
      <description>&lt;P&gt;With your current approach order matters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;carboplatin paclitaxel&lt;/STRONG&gt; will not be the same as&amp;nbsp;&lt;STRONG&gt;paclitaxel&amp;nbsp;carboplatin&lt;/STRONG&gt; and because there's no delimiter it'll be harder to separate out drugs that have two names.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this matters sort your data before you do the combination. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What are you trying to achieve that makes you think this is the correct format?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 20:22:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840673#M332400</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-25T20:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to make combine different observations in relation to a variable to make a new combo variabl</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840685#M332407</link>
      <description>This didnt work for me, and why was 200 used as the length of drug combo?</description>
      <pubDate>Tue, 25 Oct 2022 21:01:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840685#M332407</guid>
      <dc:creator>mcalde33</dc:creator>
      <dc:date>2022-10-25T21:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to make combine different observations in relation to a variable to make a new combo variabl</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840692#M332408</link>
      <description>9900001	1	n	&lt;BR /&gt;2	9900001	2	l	&lt;BR /&gt;3	9900001	2	i	&lt;BR /&gt;4	9900003	1	c	&lt;BR /&gt;5	9900005	3	c	&lt;BR /&gt;6	9900005	2	c	&lt;BR /&gt;7	9900005	1	9	&lt;BR /&gt;8	9900005	3	n	&lt;BR /&gt;9	9900008	3	n	&lt;BR /&gt;10	9900008	3	n	&lt;BR /&gt;11	9900008	3	c	&lt;BR /&gt;12	9900008	2	n	&lt;BR /&gt;13	9900008	2	c	&lt;BR /&gt;14	9900008	1	c</description>
      <pubDate>Tue, 25 Oct 2022 21:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840692#M332408</guid>
      <dc:creator>mcalde33</dc:creator>
      <dc:date>2022-10-25T21:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to make combine different observations in relation to a variable to make a new combo variabl</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840695#M332409</link>
      <description>&lt;P&gt;The employer wants it that way, im not sure.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 21:21:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840695#M332409</guid>
      <dc:creator>mcalde33</dc:creator>
      <dc:date>2022-10-25T21:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to make combine different observations in relation to a variable to make a new combo variabl</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840699#M332411</link>
      <description>&lt;P&gt;The two main method are outlined here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/d583cfa992bf56da51d435165b07e96a" target="_blank"&gt;https://gist.github.com/statgeek/d583cfa992bf56da51d435165b07e96a&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The length is set to a large number to ensure it can hold the combined values at the end. If we don't know the data, we usually guess an arbitrarily large number. Feel free to customize it to your requirements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If a solution doesn't work, you need to explain how in details.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an error in the log? It could be anything from a missing semicolon to an incorrect solution.&amp;nbsp;&lt;BR /&gt;Saying it doesn't work doesn't convey any information.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 21:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840699#M332411</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-25T21:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to make combine different observations in relation to a variable to make a new combo variabl</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840702#M332413</link>
      <description>it has already been mentioned. I sent the output I was getting, that way I conveyed the output to explain it.</description>
      <pubDate>Tue, 25 Oct 2022 22:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840702#M332413</guid>
      <dc:creator>mcalde33</dc:creator>
      <dc:date>2022-10-25T22:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to make combine different observations in relation to a variable to make a new combo variabl</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840705#M332414</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/309052"&gt;@mcalde33&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;it has already been mentioned. I sent the output I was getting, that way I conveyed the output to explain it.&lt;/BLOCKQUOTE&gt;
&lt;P class="1666736314356"&gt;Do you mean this post?&lt;/P&gt;
&lt;P class="1666736314356"&gt;Did it get cut off? Because I'm not seeing any details or explanations of what went wrong or how just a random series of data that looks nothing like your original posted data and therefore have no idea what it means.&lt;/P&gt;
&lt;P class="1666736314356"&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P class="1666736314356"&gt;&lt;SPAN&gt;9900001 1 n&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2 9900001 2 l&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3 9900001 2 i&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4 9900003 1 c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5 9900005 3 c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6 9900005 2 c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;7 9900005 1 9&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;8 9900005 3 n&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;9 9900008 3 n&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;10 9900008 3 n&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;11 9900008 3 c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;12 9900008 2 n&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;13 9900008 2 c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;14 9900008 1 c&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 22:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840705#M332414</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-25T22:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to make combine different observations in relation to a variable to make a new combo variabl</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840708#M332415</link>
      <description>This is the code used:&lt;BR /&gt;DATA drugs;&lt;BR /&gt;     Input Patient_ID  Drug_ID Drug :$20;&lt;BR /&gt;          &lt;BR /&gt;Datalines;&lt;BR /&gt;&lt;BR /&gt;9900001 1 vinorelbine&lt;BR /&gt;9900001 2 carboplatin&lt;BR /&gt;9900001 2 paclitaxel&lt;BR /&gt;9900003 1 fluorouracil&lt;BR /&gt;9900005 1 5-FU&lt;BR /&gt;9900005 1 leucovorin&lt;BR /&gt;9900005 2 fluorouracil&lt;BR /&gt;9900005 3 fluorouracil&lt;BR /&gt;9900005 3 leucovorin&lt;BR /&gt;9900008 1 fluorouracil&lt;BR /&gt;9900008 2 fluorouracil&lt;BR /&gt;9900008 2 leucovorin&lt;BR /&gt;9900008 3 fluorouracil&lt;BR /&gt;9900008 3 irinotecan&lt;BR /&gt;9900008 3 leucovorin&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;Data Drug_combo (DROP=drug);&lt;BR /&gt;     DO until (last.drug_ID);&lt;BR /&gt;     SET drugs;&lt;BR /&gt;     BY Patient_ID Drug_ID;&lt;BR /&gt;     LENGTH drug_combo $200;&lt;BR /&gt;     drug_combo= catx('', drug_combo, drug);&lt;BR /&gt;    end;&lt;BR /&gt; RUN;&lt;BR /&gt;    &lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;My log:&lt;BR /&gt; &lt;BR /&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 68         &lt;BR /&gt; 69         DATA drugs;&lt;BR /&gt; 70              Input Patient_ID  Drug_ID Drug :$20;&lt;BR /&gt; 71         &lt;BR /&gt; 72         Datalines;&lt;BR /&gt; &lt;BR /&gt; NOTE: SAS went to a new line when INPUT statement reached past the end of a line.&lt;BR /&gt; NOTE: The data set WORK.DRUGS has 14 observations and 3 variables.&lt;BR /&gt; NOTE: DATA statement used (Total process time):&lt;BR /&gt;       real time           0.00 seconds&lt;BR /&gt;       user cpu time       0.00 seconds&lt;BR /&gt;       system cpu time     0.00 seconds&lt;BR /&gt;       memory              669.78k&lt;BR /&gt;       OS Memory           23976.00k&lt;BR /&gt;       Timestamp           10/25/2022 10:23:33 PM&lt;BR /&gt;       Step Count                        24  Switch Count  2&lt;BR /&gt;       Page Faults                       0&lt;BR /&gt;       Page Reclaims                     167&lt;BR /&gt;       Page Swaps                        0&lt;BR /&gt;       Voluntary Context Switches        13&lt;BR /&gt;       Involuntary Context Switches      0&lt;BR /&gt;       Block Input Operations            0&lt;BR /&gt;       Block Output Operations           264&lt;BR /&gt;       &lt;BR /&gt; &lt;BR /&gt; 89         ;&lt;BR /&gt; 90         &lt;BR /&gt; 91         RUN;&lt;BR /&gt; 92         &lt;BR /&gt; 93         Data Drug_combo (DROP=drug);&lt;BR /&gt; 94              DO until (last.drug_ID);&lt;BR /&gt; 95              SET drugs;&lt;BR /&gt; 96              BY Patient_ID Drug_ID;&lt;BR /&gt; 97              LENGTH drug_combo $200;&lt;BR /&gt; 98              drug_combo= catx('', drug_combo, drug);&lt;BR /&gt; 99             end;&lt;BR /&gt; 100         RUN;&lt;BR /&gt; &lt;BR /&gt; NOTE: There were 14 observations read from the data set WORK.DRUGS.&lt;BR /&gt; NOTE: The data set WORK.DRUG_COMBO has 9 observations and 3 variables.&lt;BR /&gt; NOTE: DATA statement used (Total process time):&lt;BR /&gt;       real time           0.00 seconds&lt;BR /&gt;       user cpu time       0.01 seconds&lt;BR /&gt;       system cpu time     0.00 seconds&lt;BR /&gt;       memory              1070.75k&lt;BR /&gt;       OS Memory           24236.00k&lt;BR /&gt;       Timestamp           10/25/2022 10:23:33 PM&lt;BR /&gt;       Step Count                        25  Switch Count  2&lt;BR /&gt;       Page Faults                       0&lt;BR /&gt;       Page Reclaims                     210&lt;BR /&gt;       Page Swaps                        0&lt;BR /&gt;       Voluntary Context Switches        13&lt;BR /&gt;       Involuntary Context Switches      0&lt;BR /&gt;       Block Input Operations            0&lt;BR /&gt;       Block Output Operations           264&lt;BR /&gt;       &lt;BR /&gt; &lt;BR /&gt; 101        &lt;BR /&gt; 102        &lt;BR /&gt; 103        &lt;BR /&gt; 104        &lt;BR /&gt; 105        &lt;BR /&gt; 106        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 116        &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My output:&lt;BR /&gt;&lt;BR /&gt;Obs Patient_ID Drug_ID Drug&lt;BR /&gt;1 9900008 3 c&lt;BR /&gt;2 9900008 2 c&lt;BR /&gt;3 9900008 2 n&lt;BR /&gt;4 9900008 1 c&lt;BR /&gt;5 9900008 3 n&lt;BR /&gt;6 9900008 3 n&lt;BR /&gt;7 9900005 3 c&lt;BR /&gt;8 9900005 2 c&lt;BR /&gt;9 9900005 1 9&lt;BR /&gt;10 9900005 3 n&lt;BR /&gt;11 9900003 1 c&lt;BR /&gt;12 9900001 2 l&lt;BR /&gt;13 9900001 1 n&lt;BR /&gt;14 9900001 2 i</description>
      <pubDate>Tue, 25 Oct 2022 22:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840708#M332415</guid>
      <dc:creator>mcalde33</dc:creator>
      <dc:date>2022-10-25T22:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to make combine different observations in relation to a variable to make a new combo variabl</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840712#M332416</link>
      <description>&lt;P&gt;The first step is incorrect. Note the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;NOTE: SAS went to a new line when INPUT statement reached past the end of a line.&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;NOTE: The data set WORK.DRUGS has 14 observations and 3 variables.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NOTE: DATA statement used (Total process time):&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you print the input data set, the data is truncated from when it's imported, leading to the problem you're seeing.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The solution is actually fine assuming you'd be applying to actual data not just test data.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA drugs;
length drug $ 20;
Input Patient_ID Drug_ID Drug;

Datalines;

9900001 1 vinorelbine
9900001 2 carboplatin
9900001 2 paclitaxel
9900003 1 fluorouracil
9900005 1 5-FU
9900005 1 leucovorin
9900005 2 fluorouracil
9900005 3 fluorouracil
9900005 3 leucovorin
9900008 1 fluorouracil
9900008 2 fluorouracil
9900008 2 leucovorin
9900008 3 fluorouracil
9900008 3 irinotecan
9900008 3 leucovorin
;

RUN;



Data Drug_combo (DROP=drug);
DO until (last.drug_ID);
SET drugs;
BY Patient_ID Drug_ID;
LENGTH drug_combo $200;
drug_combo= catx('', drug_combo, drug);
end;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Oct 2022 22:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-make-combine-different-observations-in-relation-to-a/m-p/840712#M332416</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-25T22:39:21Z</dc:date>
    </item>
  </channel>
</rss>

