<?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: combining 2 rows of same VAR1 value but dif VAR2 and VAR3 values in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837152#M41526</link>
    <description>Thanks for your response&lt;BR /&gt;will keep that in mind. i just used different real life variable names to make the reasoning easier.&lt;BR /&gt;&lt;BR /&gt;Is there another way to do it with those character variables?</description>
    <pubDate>Thu, 06 Oct 2022 10:14:37 GMT</pubDate>
    <dc:creator>Primohunter</dc:creator>
    <dc:date>2022-10-06T10:14:37Z</dc:date>
    <item>
      <title>combining 2 rows of same VAR1 value but dif VAR2 and VAR3 values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837145#M41522</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;below you can find an example of a data set that i want to turn to the OUTPUT example below as well.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Have DATASET:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Var1&amp;nbsp; &amp;nbsp; &amp;nbsp;Var2&amp;nbsp; &amp;nbsp; &amp;nbsp;Var3&amp;nbsp; &amp;nbsp; &amp;nbsp;Var4&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Nick&amp;nbsp; &amp;nbsp; &amp;nbsp; ran1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/P&gt;
&lt;P&gt;Nick&amp;nbsp; &amp;nbsp; &amp;nbsp; ran1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;/P&gt;
&lt;P&gt;John&amp;nbsp; &amp;nbsp; &amp;nbsp;ran2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&lt;/P&gt;
&lt;P&gt;John&amp;nbsp; &amp;nbsp; &amp;nbsp;ran2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;
&lt;P&gt;George&amp;nbsp; ran3&amp;nbsp; &amp;nbsp; &amp;nbsp; N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output (Want) Dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Var1&amp;nbsp; &amp;nbsp; &amp;nbsp;Var2&amp;nbsp; &amp;nbsp; &amp;nbsp;Var3&amp;nbsp; &amp;nbsp; &amp;nbsp;Var4&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Nick&amp;nbsp; &amp;nbsp; &amp;nbsp; ran1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;/P&gt;
&lt;P&gt;John&amp;nbsp; &amp;nbsp; &amp;nbsp;ran2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;
&lt;P&gt;George&amp;nbsp; ran3&amp;nbsp; &amp;nbsp; &amp;nbsp; N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 09:43:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837145#M41522</guid>
      <dc:creator>Primohunter</dc:creator>
      <dc:date>2022-10-06T09:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: combining 2 rows of same VAR1 value but dif VAR2 and VAR3 values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837149#M41523</link>
      <description>&lt;P&gt;Please explain the logic that allows you to transform the HAVE data set into the WANT data set.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 09:52:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837149#M41523</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-06T09:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: combining 2 rows of same VAR1 value but dif VAR2 and VAR3 values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837150#M41524</link>
      <description>&lt;P&gt;lets just say that for some reason nick and john are both qualified for having VAR 3 AND VAR 4&amp;nbsp; (e.g. 'Y') but the input program could only accept&amp;nbsp; only one VAR input at a time.&lt;/P&gt;
&lt;P&gt;For example&lt;/P&gt;
&lt;P&gt;nick wears a black and white shirt&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so the dataset becomes as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;PROBLEMATIC INPUT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DESIRED FORMAT FOR FURTHER ANALYSIS&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Name&amp;nbsp; &amp;nbsp; &amp;nbsp;Status&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;White&amp;nbsp; &amp;nbsp;Black&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ---&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Name&amp;nbsp; &amp;nbsp; &amp;nbsp;Status&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;White&amp;nbsp; &amp;nbsp;Black&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Nick&amp;nbsp; &amp;nbsp; &amp;nbsp; Dressed&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Nick&amp;nbsp; &amp;nbsp; &amp;nbsp; Dressed&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nick&amp;nbsp; &amp;nbsp; &amp;nbsp; Dressed&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 10:02:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837150#M41524</guid>
      <dc:creator>Primohunter</dc:creator>
      <dc:date>2022-10-06T10:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: combining 2 rows of same VAR1 value but dif VAR2 and VAR3 values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837151#M41525</link>
      <description>&lt;P&gt;This would be much easier if you used 0s and 1s instead of N and Y.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input var1 $ var2 $ var3 var4;
    cards;
nick ran1 1 0
nick ran1 0 1
john ran2 1 0
john ran2 0 1
george ran3 0 1
;
proc summary data=have nway;
    class var1 var2;
    var var3 var4;
    output out=want max=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a side issue, please don't use different variable names in your examples than in your original data set.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 10:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837151#M41525</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-06T10:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: combining 2 rows of same VAR1 value but dif VAR2 and VAR3 values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837152#M41526</link>
      <description>Thanks for your response&lt;BR /&gt;will keep that in mind. i just used different real life variable names to make the reasoning easier.&lt;BR /&gt;&lt;BR /&gt;Is there another way to do it with those character variables?</description>
      <pubDate>Thu, 06 Oct 2022 10:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837152#M41526</guid>
      <dc:creator>Primohunter</dc:creator>
      <dc:date>2022-10-06T10:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: combining 2 rows of same VAR1 value but dif VAR2 and VAR3 values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837153#M41527</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415086"&gt;@Primohunter&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks for your response&lt;BR /&gt;will keep that in mind. i just used different real life variable names to make the reasoning easier.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Reasoning is easier if you use the same variable names in your examples and actual data. We're trying to help you, but you have to help us too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Is there another way to do it with those character variables?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Convert char to numeric, use PROC SUMMARY as I have shown, and then convert 0 and 1 back to N and Y.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 10:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837153#M41527</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-06T10:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: combining 2 rows of same VAR1 value but dif VAR2 and VAR3 values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837155#M41528</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415086"&gt;@Primohunter&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Is there another way to do it with those character variables?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You could use PROC SQL, but the syntax is less elegant than the succinct "&lt;FONT face="courier new,courier"&gt;max=&lt;/FONT&gt;" of PROC SUMMARY's OUTPUT statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (var1-var4)($);
cards;
Nick ran1 Y N
Nick ran1 N Y
John ran2 Y N
John ran2 N Y
George ran3 N Y
;

proc sql;
create table want as
select var1, var2, max(var3) as var3, max(var4) as var4
from have
group by 2, 1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The "maximum" here is based on the alphabetical order 'N' &amp;lt; 'Y'.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 10:40:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837155#M41528</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-10-06T10:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: combining 2 rows of same VAR1 value but dif VAR2 and VAR3 values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837163#M41529</link>
      <description>&lt;P&gt;And so I still believe, despite the fine example from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;, that handling binary variables via numeric 0s and 1s is superior for a number of reasons, and I urge all readers of this thread to use numeric 0s and 1s for binary variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If the real problem has 25 variables, instead of the 4, much less typing in PROC SUMMARY than in PROC SQL and therefore also less chance for typographical errors&lt;/LI&gt;
&lt;LI&gt;PROC SUMMARY will compute the percent of 1 simply by asking for the MEAN (the mean of a 0/1 variable is the percent of ones)&lt;/LI&gt;
&lt;LI&gt;Less typing to enter a 0 or 1 compared to 'N' or 'Y' and hence less chance for typographical errors&lt;/LI&gt;
&lt;LI&gt;If a different question was asked, for example does any ID have more than 3 observations with 'Y', if you use 0/1s again PROC SUMMARY makes the solution easy, while otherwise you have to count the 'Y' values within an ID, which is certainly do-able, but not as easy as using PROC SUMMARY&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 06 Oct 2022 11:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combining-2-rows-of-same-VAR1-value-but-dif-VAR2-and-VAR3-values/m-p/837163#M41529</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-06T11:40:49Z</dc:date>
    </item>
  </channel>
</rss>

