<?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: Comparing two values in a column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786380#M251070</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;I tried that, it's similar to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; first posted. You have N=8. N should be =4 because I have 4 patients. In proc ttest for example there is a way to pair two columns. For a example using your tranposed data set 'wide'. Is there something like that in proc means or any other procedure to calculate the mean, min, max etc?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc ttest data= wide plots=none;&lt;BR /&gt;&lt;STRONG&gt;paired&lt;/STRONG&gt; visit_1*visit_2;&lt;BR /&gt;ods output ttests=ttest_1;&lt;BR /&gt;ods output Statistics=Stat_1;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Dec 2021 20:55:42 GMT</pubDate>
    <dc:creator>Anita_n</dc:creator>
    <dc:date>2021-12-16T20:55:42Z</dc:date>
    <item>
      <title>Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786321#M251036</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;I have a data set that looks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input patid  visit  var;
datalines;
1 1 5
2 1 2
5 3 9
1 2 10
3 1 8
7 4 6
1 3 15
2 2 4
5 1 14
5 2 11
3 2 16
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I wish to search for the patid's and their corresponding var 's in visit 1 which also occurs in visit 2 and find their mean, standard deviation, min, max, and N&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case it will be the following patid's&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydat;
input patid  visite  var;
datalines;
1 1 5
1 2 10
2 1 2
2 2 4
3 1 8
3 2 16
5 1 14
5 2 11
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I will appreciate any help. Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 17:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786321#M251036</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-12-16T17:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786322#M251037</link>
      <description>&lt;P&gt;Could you please explain this part?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"...&amp;nbsp;&lt;SPAN&gt;and their corresponding var 's in visit 1 which also occurs in visit 2"&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 17:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786322#M251037</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-16T17:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786325#M251038</link>
      <description>&lt;P&gt;Which do you want, the filtered data set or the mean, std and such? The later doesn't require much work:&lt;/P&gt;
&lt;PRE&gt;proc means data=test mean std min max n;
   where visit in (1 2);
   class patid;
   var var;
run;&lt;/PRE&gt;
&lt;P&gt;The where statement in the proc means restricts the data to only visit numbers 1 and 2 and doesn't require any special coding to handle the cases where there are visit number 1 without a 2 , or possibly a visit number 2 without a visit 1 for each patient id.&lt;/P&gt;
&lt;P&gt;Procedures Report and Tabulate would also do this.&lt;/P&gt;
&lt;P&gt;If you need a data set with the summaries, say so.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 17:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786325#M251038</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-16T17:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786327#M251040</link>
      <description>&lt;P&gt;I mean for example the patient with the&amp;nbsp; id=1 has at visit 1 var=5 and at visit 2 var=10. I only wish to search for patients whose patid occurs in visit1 then search for exactly these patids in visit2. That means if a patient has visit 1 but does not occur in visit2, this is not considered. At the end, wish to do the above statistics on the column 'var'&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydat;
input patid  visite  var;
datalines;
1 1 5
1 2 10
2 1 2
2 2 4
3 1 8
3 2 16
5 1 14
5 2 11
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I hope I could explain better&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 17:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786327#M251040</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-12-16T17:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786335#M251046</link>
      <description>Sounds like you want patients who have both a visit 1 and 2 and then want to summarize the variable VAR? Visits over two are disregarded?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 16 Dec 2021 17:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786335#M251046</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-16T17:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786336#M251047</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;thanks for that. I will try that now to see if it works&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 17:55:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786336#M251047</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-12-16T17:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786337#M251048</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input patid  visit  var;
datalines;
1 1 5
2 1 2
5 3 9
1 2 10
3 1 8
7 4 6
1 3 15
2 2 4
5 1 14
5 2 11
3 2 16
;
run;

proc sort data=test;
by patid visit;
run;

proc sql;
create table valid_records as
select * 
from test
/*filters only visit=1 or 2 into data*/
where visit in (1, 2)
group by patid
/*ensures record has both a 1 &amp;amp; 2, ie 2 distinct values*/
having count(distinct visit)=2;
quit;

*summarizes across all values;
proc means data=valid_records n mean median std min max;
var var;
ods output summary = summary_visits;
run;

proc print data=summary_visits;
run;

*summarizes by patid values;
proc means data=valid_records NWAY n mean median std min max;
class patid;
var var;
ods output summary = summary_visits_ID;
run;

proc print data=summary_visits_ID;
run;

*Summarize by visit;
proc means data=valid_records NWAY n mean median std min max;
class visit;
var var;
ods output summary = summary_visits_by_visit;
run;


*transpose to a wide format for example - may make more sense to you in this format;
proc transpose data=test out=wide (where = (not missing(visit_2))) prefix=visit_;
where visit in (1, 2);
by patid;
id visit;
var var;
run;

proc means data=wide NWAY n mean median std min max;
var visit_:;
ods output summary = summary_visits2;
run;

proc print data=summary_visits2;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/168930"&gt;@Anita_n&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;I have a data set that looks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input patid  visit  var;
datalines;
1 1 5
2 1 2
5 3 9
1 2 10
3 1 8
7 4 6
1 3 15
2 2 4
5 1 14
5 2 11
3 2 16
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I wish to search for the patid's and their corresponding var 's in visit 1 which also occurs in visit 2 and find their mean, standard deviation, min, max, and N&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case it will be the following patid's&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydat;
input patid  visite  var;
datalines;
1 1 5
1 2 10
2 1 2
2 2 4
3 1 8
3 2 16
5 1 14
5 2 11
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I will appreciate any help. Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 20:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786337#M251048</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-16T20:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786338#M251049</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;: I tried that your code but that is not exactly&amp;nbsp; what I want. If I use your code as below I get N=8&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=test mean std min max n;
   where visit in (1 2) ;
     var var;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if I use the following code to select the number of patids in visit1, I get N=4&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test2 as select patid as patid, var , visit from test
where visit =1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That means my N can be less than 4 but not greater 4. From these 4. I now need to search if these 4 patid's also occur in visit 2. If yes then they will be included in my statistics. I hope you can understand what I mean&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>Thu, 16 Dec 2021 18:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786338#M251049</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-12-16T18:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786345#M251051</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/168930"&gt;@Anita_n&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;: I tried that your code but that is not exactly&amp;nbsp; what I want. If I use your code as below I get N=8&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=test mean std min max n;
   where visit in (1 2) ;
     var var;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if I use the following code to select the number of patids in visit1, I get N=4&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test2 as select patid as patid, var , visit from test
where visit =1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That means my N can be less than 4 but not greater 4. From these 4. I now need to search if these 4 patid's also occur in visit 2. If yes then they will be included in my statistics. I hope you can understand what I mean&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;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which means your example data is insufficient for your problem description. The N i got for each Id with your example data was 2 for each Patientid. AND your description appears very odd which is why&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; asked for clarification of that phrase. Which means describe by selecting observations and showing the desired calculation.&lt;/P&gt;
&lt;P&gt;The where clause supplied exactly matches your requested example Mydat data set:&lt;/P&gt;
&lt;PRE&gt;data selected;
   set test;
   where visit in (1 2);
run;
proc sort data=selected;
  by patid visit;
run;&lt;/PRE&gt;
&lt;P&gt;which results in:&lt;/P&gt;
&lt;PRE&gt;patid    visit    var

  1        1        5
  1        2       10
  2        1        2
  2        2        4
  3        1        8
  3        2       16
  5        1       14
  5        2       11
&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Dec 2021 18:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786345#M251051</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-16T18:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786346#M251052</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;: It should something Iike this, first of all search for the patids that occurs in visit1 then something like this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if (patids in visit1 occurs in visit2) then include this in my dataset&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 18:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786346#M251052</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-12-16T18:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786349#M251054</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/168930"&gt;@Anita_n&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;: It should something Iike this, first of all search for the patids that occurs in visit1 then something like this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if (patids in visit1 occurs in visit2) then include this in my dataset&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Honestly, this doesn't help me at all understand, as "visit1 occurs in visit2" means nothing to me. I think your earlier explanation was more helpful "&lt;SPAN&gt;That means if a patient has visit 1 but does not occur in visit2, this is not considered." But you still have not answered the questions from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sounds like you want patients who have both a visit 1 and 2 and then want to summarize the variable VAR? Visits over two are disregarded?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 16 Dec 2021 18:54:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786349#M251054</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-16T18:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786353#M251058</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;: Yes this statement from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;:&lt;FONT color="#999999"&gt;&lt;SPAN&gt;Sounds like you want patients who have both a visit 1 and 2 and then want to summarize the variable VAR? Visits over two are disregarded?&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;is right&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 19:09:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786353#M251058</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-12-16T19:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786361#M251063</link>
      <description>Have you had a chance to verify my solution?</description>
      <pubDate>Thu, 16 Dec 2021 20:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786361#M251063</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-16T20:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786365#M251065</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;Yes I did, I found it okay till where you created the valid_records but then you summarized across all values which is not what I want, then you summarized by patid, I did not understand why.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your tranposed dataset is close to what I want. But I would then wish to do a summarized statistics on these two cloumns (visit_1 and visit_2). Is there any way to do a summarized statistics on both columns?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 20:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786365#M251065</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-12-16T20:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786368#M251066</link>
      <description>Please check the edited posts - note that my proc means was originally wrong, I had it pointed at your original data set not the filtered data. Try these ones and one should be the correct answer. Mostly because I don't think there's any possible way to slice the data &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 16 Dec 2021 20:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786368#M251066</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-16T20:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786380#M251070</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;I tried that, it's similar to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; first posted. You have N=8. N should be =4 because I have 4 patients. In proc ttest for example there is a way to pair two columns. For a example using your tranposed data set 'wide'. Is there something like that in proc means or any other procedure to calculate the mean, min, max etc?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc ttest data= wide plots=none;&lt;BR /&gt;&lt;STRONG&gt;paired&lt;/STRONG&gt; visit_1*visit_2;&lt;BR /&gt;ods output ttests=ttest_1;&lt;BR /&gt;ods output Statistics=Stat_1;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 20:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786380#M251070</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-12-16T20:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786386#M251073</link>
      <description>Only the first proc means has N=8 the remaining have other N's that reflect different summaries. &lt;BR /&gt;All of the proc means are also saving the output to a data set. &lt;BR /&gt;Please review the code in detail.</description>
      <pubDate>Thu, 16 Dec 2021 21:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786386#M251073</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-16T21:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786442#M251098</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;: I finally solved it this way&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test1 as select patid as patid1, visit as visit1 , var as var1 from test where visit=1;

create table test2 as select patid as patid2, visit as visit2 , var as var2 from test where visit=2;

create table test3 as select a.*, b.*  from test1 as a right join test2 as b on a.patid1=b.patid2;

quit;

proc means data=test3 n mean std min max nmiss;
var  var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and as result :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Anita_n_0-1639740776977.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66820iE6673B177DF41652/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Anita_n_0-1639740776977.png" alt="Anita_n_0-1639740776977.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;That is what I wanted, thanks for the help&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 11:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786442#M251098</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-12-17T11:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786474#M251117</link>
      <description>&lt;P&gt;or just&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   select n(a.var) as n, mean(a.var) as mean, std(a.var) as std /*  insert other stats */
      from work.test a
         join work.test b on a.patid = b.patid and a.visit = 1 and b.visit = 2
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Dec 2021 14:34:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786474#M251117</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-12-17T14:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two values in a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786499#M251131</link>
      <description>Which is identical to the last proc means in my example.</description>
      <pubDate>Fri, 17 Dec 2021 16:04:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-two-values-in-a-column/m-p/786499#M251131</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-17T16:04:03Z</dc:date>
    </item>
  </channel>
</rss>

