<?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: Multiple lines varialbe merge with one line variable (to comparing their value each other  pairw in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796004#M81570</link>
    <description>Actually real task here is that comparing survive stata pairwise for subject. The one surviving longer than the other one then get +1 point; the one surviving shorter than the other one then get -1 point; if surviving time is the same then get 0 point. Finally calculate the sum point per subject.&lt;BR /&gt;&lt;BR /&gt;Now I think of a way that merge per subject value into same raw and calculate.&lt;BR /&gt;&lt;BR /&gt;If you any better way of idea, please kindly help.</description>
    <pubDate>Mon, 14 Feb 2022 07:41:44 GMT</pubDate>
    <dc:creator>Garyho</dc:creator>
    <dc:date>2022-02-14T07:41:44Z</dc:date>
    <item>
      <title>Multiple lines varialbe merge with one line variable (to comparing their value each other  pairwise)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/795996#M81566</link>
      <description>&lt;P&gt;I have a dataset like this( I'll just list a few lines, actually it might be&amp;nbsp; many line&amp;nbsp; such as 20 30 ..):&lt;/P&gt;&lt;P&gt;subjid&amp;nbsp; value&lt;/P&gt;&lt;P&gt;001&amp;nbsp; &amp;nbsp; &amp;nbsp;12&lt;/P&gt;&lt;P&gt;002&amp;nbsp; &amp;nbsp; &amp;nbsp;25&lt;/P&gt;&lt;P&gt;003&amp;nbsp; &amp;nbsp; &amp;nbsp;30&lt;/P&gt;&lt;P&gt;004&amp;nbsp; &amp;nbsp; &amp;nbsp;6&lt;/P&gt;&lt;P&gt;004&amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And&amp;nbsp; I need to&amp;nbsp;comparing their value each other&amp;nbsp; pairwise ,so&amp;nbsp; I&amp;nbsp; want to output:&lt;/P&gt;&lt;P&gt;subjid&amp;nbsp; value&amp;nbsp;value_1&amp;nbsp; value_2&amp;nbsp; value_3&amp;nbsp; value_4&amp;nbsp; &amp;nbsp;value_5&lt;/P&gt;&lt;P&gt;001&amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&gt;002&amp;nbsp; &amp;nbsp; &amp;nbsp;25 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&gt;003&amp;nbsp; &amp;nbsp; &amp;nbsp;30 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&gt;004&amp;nbsp; &amp;nbsp; &amp;nbsp;6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&gt;004&amp;nbsp; &amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&gt;.......&lt;/P&gt;&lt;P&gt;Dear SAS expert,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you create a macro program to do that ?? many thank.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 07:01:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/795996#M81566</guid>
      <dc:creator>Garyho</dc:creator>
      <dc:date>2022-02-14T07:01:58Z</dc:date>
    </item>
    <item>
      <title>Multiple lines varialbe merge with one line variable (to comparing their value each other  pairwise)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/795997#M81568</link>
      <description>&lt;P&gt;005&amp;nbsp; &amp;nbsp; &amp;nbsp;9 ..... And&amp;nbsp; I need to&amp;nbsp;comparing their value each other&amp;nbsp; pairwise ,so&amp;nbsp; I&amp;nbsp; want to output: subjid&amp;nbsp; value&amp;nbsp;value_1&amp;nbsp; value_2&amp;nbsp; value_3&amp;nbsp; value_4&amp;nbsp; &amp;nbsp;value_5 001&amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9 002&amp;nbsp; &amp;nbsp; &amp;nbsp;25 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9 003&amp;nbsp; &amp;nbsp; &amp;nbsp;30 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9 004&amp;nbsp; &amp;nbsp; &amp;nbsp;6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9 005&amp;nbsp; &amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9 ....... Dear SAS expert, Could you create a macro program to do that ?? many thank.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 07:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/795997#M81568</guid>
      <dc:creator>Garyho</dc:creator>
      <dc:date>2022-02-14T07:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines varialbe merge with one line variable (to comparing their value each other  pairw</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/795998#M81567</link>
      <description>&lt;P&gt;This seems to be part of a larger task. And if so, there is definitely a better way to get there than to create columns for all of your observations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the real task here?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 07:17:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/795998#M81567</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-14T07:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines varialbe merge with one line variable (to comparing their value each other  pairw</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/795999#M81569</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416631"&gt;@Garyho&lt;/a&gt;&amp;nbsp;, Also, I merged your two similar questions into one &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 07:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/795999#M81569</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-14T07:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines varialbe merge with one line variable (to comparing their value each other  pairw</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796004#M81570</link>
      <description>Actually real task here is that comparing survive stata pairwise for subject. The one surviving longer than the other one then get +1 point; the one surviving shorter than the other one then get -1 point; if surviving time is the same then get 0 point. Finally calculate the sum point per subject.&lt;BR /&gt;&lt;BR /&gt;Now I think of a way that merge per subject value into same raw and calculate.&lt;BR /&gt;&lt;BR /&gt;If you any better way of idea, please kindly help.</description>
      <pubDate>Mon, 14 Feb 2022 07:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796004#M81570</guid>
      <dc:creator>Garyho</dc:creator>
      <dc:date>2022-02-14T07:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines varialbe merge with one line variable (to comparing their value each other  pairw</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796005#M81571</link>
      <description>&lt;P&gt;Ok. Can you explain your problem from your sample data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does your desired result look like from that? Makes it much easier to provide a usable code answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 07:44:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796005#M81571</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-14T07:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines varialbe merge with one line variable (to comparing their value each other  pairw</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796045#M81575</link>
      <description>&lt;PRE&gt;data have;
input subjid  value;
format subjid z3.;
cards;
001     12
002     25
003     30
004     6
004     9
;

proc transpose data=have out=temp prefix=value_;
var value;
run;

data want;
 set have;
 if _n_=1 then set temp(drop=_name_);
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Feb 2022 13:54:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796045#M81575</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-02-14T13:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines varialbe merge with one line variable (to comparing their value each other  pairw</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796058#M81577</link>
      <description>data subject;&lt;BR /&gt;input subject survive_state ;&lt;BR /&gt;cards;&lt;BR /&gt;1001 0&lt;BR /&gt;1002 1&lt;BR /&gt;1003 4&lt;BR /&gt;1004 5&lt;BR /&gt;1005 2&lt;BR /&gt;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data subject_survive;&lt;BR /&gt;input subject survive_state survive_state_1001 survive_state_1002 survive_state_1003 survive_state_1004 survive_state_1005;&lt;BR /&gt;cards;&lt;BR /&gt;1001 0 0 1 4 5 2&lt;BR /&gt;1002 1 0 1 4 5 2&lt;BR /&gt;1003 4 0 1 4 5 2&lt;BR /&gt;1004 5 0 1 4 5 2&lt;BR /&gt;1005 2 0 1 4 5 2&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data final;&lt;BR /&gt;set subject_survive;&lt;BR /&gt;length total_1 total_2 total_3 total_4 total_all 8.;&lt;BR /&gt;&lt;BR /&gt;if subject=1001 then do;&lt;BR /&gt;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1002 then total_1=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1003 then total_2=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1004 then total_3=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1005 then total_4=-1;&lt;BR /&gt;&lt;BR /&gt;if survive_state=survive_state_1002 then total_1=0;&lt;BR /&gt;if survive_state=survive_state_1003 then total_2=0;&lt;BR /&gt;if survive_state=survive_state_1004 then total_3=0;&lt;BR /&gt;if survive_state=survive_state_1005 then total_4=0;&lt;BR /&gt;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1002 then total_1=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1003 then total_2=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1004 then total_3=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1005 then total_4=1;&lt;BR /&gt;total_all=sum(total_1,total_2,total_3,total_4);&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if subject=1002 then do;&lt;BR /&gt;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1001 then total_1=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1003 then total_2=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1004 then total_3=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1005 then total_4=-1;&lt;BR /&gt;&lt;BR /&gt;if survive_state=survive_state_1001 then total_1=0;&lt;BR /&gt;if survive_state=survive_state_1003 then total_2=0;&lt;BR /&gt;if survive_state=survive_state_1004 then total_3=0;&lt;BR /&gt;if survive_state=survive_state_1005 then total_4=0;&lt;BR /&gt;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1001 then total_1=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1003 then total_2=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1004 then total_3=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1005 then total_4=1;&lt;BR /&gt;total_all=sum(total_1,total_2,total_3,total_4);&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;if subject=1002 then do;&lt;BR /&gt;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1001 then total_1=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1003 then total_2=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1004 then total_3=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1005 then total_4=-1;&lt;BR /&gt;&lt;BR /&gt;if survive_state=survive_state_1001 then total_1=0;&lt;BR /&gt;if survive_state=survive_state_1003 then total_2=0;&lt;BR /&gt;if survive_state=survive_state_1004 then total_3=0;&lt;BR /&gt;if survive_state=survive_state_1005 then total_4=0;&lt;BR /&gt;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1001 then total_1=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1003 then total_2=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1004 then total_3=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1005 then total_4=1;&lt;BR /&gt;total_all=sum(total_1,total_2,total_3,total_4);&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;if subject=1003 then do;&lt;BR /&gt;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1001 then total_1=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1002 then total_2=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1004 then total_3=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1005 then total_4=-1;&lt;BR /&gt;&lt;BR /&gt;if survive_state=survive_state_1001 then total_1=0;&lt;BR /&gt;if survive_state=survive_state_1002 then total_2=0;&lt;BR /&gt;if survive_state=survive_state_1004 then total_3=0;&lt;BR /&gt;if survive_state=survive_state_1005 then total_4=0;&lt;BR /&gt;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1001 then total_1=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1002 then total_2=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1004 then total_3=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1005 then total_4=1;&lt;BR /&gt;total_all=sum(total_1,total_2,total_3,total_4);&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if subject=1004 then do;&lt;BR /&gt;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1001 then total_1=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1003 then total_2=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1002 then total_3=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1005 then total_4=-1;&lt;BR /&gt;&lt;BR /&gt;if survive_state=survive_state_1001 then total_1=0;&lt;BR /&gt;if survive_state=survive_state_1003 then total_2=0;&lt;BR /&gt;if survive_state=survive_state_1002 then total_3=0;&lt;BR /&gt;if survive_state=survive_state_1005 then total_4=0;&lt;BR /&gt;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1001 then total_1=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1003 then total_2=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1002 then total_3=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1005 then total_4=1;&lt;BR /&gt;total_all=sum(total_1,total_2,total_3,total_4);&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;if subject=1005 then do;&lt;BR /&gt;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1001 then total_1=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1003 then total_2=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1002 then total_3=-1;&lt;BR /&gt;if survive_state&amp;lt;survive_state_1004 then total_4=-1;&lt;BR /&gt;&lt;BR /&gt;if survive_state=survive_state_1001 then total_1=0;&lt;BR /&gt;if survive_state=survive_state_1003 then total_2=0;&lt;BR /&gt;if survive_state=survive_state_1002 then total_3=0;&lt;BR /&gt;if survive_state=survive_state_1004 then total_4=0;&lt;BR /&gt;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1001 then total_1=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1003 then total_2=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1002 then total_3=1;&lt;BR /&gt;if survive_state&amp;gt;survive_state_1004 then total_4=1;&lt;BR /&gt;total_all=sum(total_1,total_2,total_3,total_4);&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;This is sample code to help you realize question .Dataset subjectis raw dataset. and I want to transport Dataset subjectis to&lt;BR /&gt;subject_survive,but now I has no idea how to transport effectively in macro code. And fianlly, What result I want is like dataset final.&lt;BR /&gt;I appreciate very much if have any idea in macro step to resolve.&lt;BR /&gt;a</description>
      <pubDate>Mon, 14 Feb 2022 14:31:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796058#M81577</guid>
      <dc:creator>Garyho</dc:creator>
      <dc:date>2022-02-14T14:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines varialbe merge with one line variable (to comparing their value each other  pairw</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796079#M81578</link>
      <description>&lt;P&gt;Just for complete case I would add:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
 if _n_=1 then set temp(drop=_name_);

 array V value_:;

 compare = 0;
 do over V;
  compare + sign(value - V);
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 16:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796079#M81578</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-02-14T16:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines varialbe merge with one line variable (to comparing their value each other  pairw</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796082#M81579</link>
      <description>&lt;P&gt;Just for fun, one more approach without transposing, just with sorting (and few more obs for testing "ties").&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input subjid  value;
format subjid z3.;
cards;
001     12
002     25
003     30
004     6
005     9
006     25
007     6
;

data want;
  do _N_ = 1 by 1 until(last.value);
    set want nobs = nobs curobs = curobs;
    by value;
    if first.value then compare = (curobs - 1);
    if last.value  then compare = compare - (nobs - curobs);
  end;

  do _N_ = 1 to _N_;
    set want;
    output;
  end;
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;[EDIT] if there are no ties it reduces to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input subjid  value;
format subjid z3.;
cards;
001     12
002     25
003     30
004     16
005     9
006     26
007     6
;
run;

proc sort data = have out = want;
  by value;
run;

data want;
    set want nobs = nobs curobs = curobs;
    compare = (curobs - 1) - (nobs - curobs);
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 16:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796082#M81579</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-02-14T16:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines varialbe merge with one line variable (to comparing their value each other  pairw</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796194#M81580</link>
      <description>This is magic code I had never seen before. I run your code in sas eg 9.3 and a error message hanppen in log file ,like :&lt;BR /&gt;&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: END, INDSNAME, KEY, KEYS, NOBS, POINT.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;&lt;BR /&gt;it might something wrong in code "curobs = curobs;"&lt;BR /&gt;&lt;BR /&gt;And I know little about curobs funstion , May I ask question that What is curobs's role in code??&lt;BR /&gt;&lt;BR /&gt;Any way, Thank you very much for providing many new ideas and code.</description>
      <pubDate>Tue, 15 Feb 2022 01:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796194#M81580</guid>
      <dc:creator>Garyho</dc:creator>
      <dc:date>2022-02-15T01:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lines varialbe merge with one line variable (to comparing their value each other  pairw</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796243#M81581</link>
      <description>&lt;P&gt;9.3... that may be the reason why it is not working. Probably, the curobs= option was introduced in 9.4.&lt;/P&gt;
&lt;P&gt;Here is the documentation for the SET statement: &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lestmtsref/p00hxg3x8lwivcn1f0e9axziw57y.htm#n19qtk2v7izsqen1n0am0e5wq268" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lestmtsref/p00hxg3x8lwivcn1f0e9axziw57y.htm#n19qtk2v7izsqen1n0am0e5wq268&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;and some example:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lestmtsref/p00hxg3x8lwivcn1f0e9axziw57y.htm#p1pp7725k3m4g5n18civhw1vx2s5" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lestmtsref/p00hxg3x8lwivcn1f0e9axziw57y.htm#p1pp7725k3m4g5n18civhw1vx2s5&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Curobs= creates a variable which keeps the number of currently read observation (the real observation number from the data set, so even if WHERE is applied it will return the real obs number).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In case there are &lt;U&gt;no ties&lt;/U&gt; in your data on the VALUE variable you can use the following code (since here the _N_ imitates the curobs= quite well):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input subjid  value;
format subjid z3.;
cards;
001     12
002     25
003     30
004     16
005     9
006     26
007     6
;
run;

proc sort data = have out = want;
  by value;
run;

data want;
    set want nobs = nobs;
    compare = (_N_ - 1) - (nobs - _N_);
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 10:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-lines-varialbe-merge-with-one-line-variable-to/m-p/796243#M81581</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-02-15T10:14:25Z</dc:date>
    </item>
  </channel>
</rss>

