<?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 overcome with ID var values occur n times in Proc tranpose? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-overcome-with-ID-var-values-occur-n-times-in-Proc/m-p/414645#M101601</link>
    <description>&lt;P&gt;Required Output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;name id test_1 test_2 test_3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JOHN A01&amp;nbsp; &amp;nbsp;89 90 92&lt;BR /&gt;JOHN A01&amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp;95&lt;BR /&gt;MARY A02&amp;nbsp; &amp;nbsp;92&amp;nbsp; .&amp;nbsp; &amp;nbsp;81&lt;BR /&gt;MARY A02&amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; 85&lt;/P&gt;</description>
    <pubDate>Sun, 19 Nov 2017 09:21:24 GMT</pubDate>
    <dc:creator>rajeshalwayswel</dc:creator>
    <dc:date>2017-11-19T09:21:24Z</dc:date>
    <item>
      <title>How to overcome with ID var values occur n times in Proc tranpose?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-overcome-with-ID-var-values-occur-n-times-in-Proc/m-p/414624#M101595</link>
      <description>&lt;P&gt;data dat3;&lt;BR /&gt;input name $ id $ exam score;&lt;BR /&gt;datalines;&lt;BR /&gt;John A01 1 89&lt;BR /&gt;John A01 2 90&lt;BR /&gt;John A01 3 92&lt;BR /&gt;John A01 3 95&lt;BR /&gt;Mary A02 1 92&lt;BR /&gt;Mary A02 3 81&lt;BR /&gt;Mary A02 3 85&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc transpose data=dat3 out=dat3_out1 (drop=_name_) prefix=test_;&lt;BR /&gt;var score;&lt;BR /&gt;by name;&lt;BR /&gt;id exam;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Log Issue:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ERROR: The ID value "test_3" occurs twice in the same BY group.&lt;BR /&gt;NOTE: The above message was for the following BY group:&lt;BR /&gt;name=John&lt;BR /&gt;ERROR: The ID value "test_3" occurs twice in the same BY group.&lt;BR /&gt;NOTE: The above message was for the following BY group:&lt;BR /&gt;name=Mary&lt;BR /&gt;ERROR: All BY groups were bad.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: There were 7 observations read from the data set WORK.DAT3.&lt;BR /&gt;WARNING: The data set WORK.DAT3_OUT1 may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 0 variables.&lt;BR /&gt;WARNING: Data set WORK.DAT3_OUT1 was not replaced because this step was stopped.&lt;BR /&gt;NOTE: PROCEDURE TRANSPOSE used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.01 seconds&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>Sat, 18 Nov 2017 17:29:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-overcome-with-ID-var-values-occur-n-times-in-Proc/m-p/414624#M101595</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2017-11-18T17:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to overcome with ID var values occur n times in Proc tranpose?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-overcome-with-ID-var-values-occur-n-times-in-Proc/m-p/414625#M101596</link>
      <description>&lt;P&gt;The first step has nothing to do with programming.&amp;nbsp; What do you want the result to look like?&amp;nbsp; You have two observations for John, A01, exam 3. Do you want to use the 89 and ignore the 95, or use the 95 and ignore the 89?&amp;nbsp; Do you want both?&amp;nbsp; If so, what would the output data set look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your answers determine how the program needs to change.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Nov 2017 17:52:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-overcome-with-ID-var-values-occur-n-times-in-Proc/m-p/414625#M101596</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-18T17:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to overcome with ID var values occur n times in Proc tranpose?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-overcome-with-ID-var-values-occur-n-times-in-Proc/m-p/414645#M101601</link>
      <description>&lt;P&gt;Required Output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;name id test_1 test_2 test_3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JOHN A01&amp;nbsp; &amp;nbsp;89 90 92&lt;BR /&gt;JOHN A01&amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp;95&lt;BR /&gt;MARY A02&amp;nbsp; &amp;nbsp;92&amp;nbsp; .&amp;nbsp; &amp;nbsp;81&lt;BR /&gt;MARY A02&amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; 85&lt;/P&gt;</description>
      <pubDate>Sun, 19 Nov 2017 09:21:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-overcome-with-ID-var-values-occur-n-times-in-Proc/m-p/414645#M101601</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2017-11-19T09:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to overcome with ID var values occur n times in Proc tranpose?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-overcome-with-ID-var-values-occur-n-times-in-Proc/m-p/414646#M101602</link>
      <description>&lt;P&gt;Make a group variable before proc transpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dat3;
input name $ id $ exam score;
datalines;
John A01 1 89
John A01 2 90
John A01 3 92
John A01 3 95
Mary A02 1 92
Mary A02 3 81
Mary A02 3 85
;
run;

data temp;
 set dat3;
 by name id;
 if first.id or exam=lag(exam) then group+1;
run;

proc transpose data=temp out=want prefix=test_;
by name id group;
id exam;
var score;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Nov 2017 09:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-overcome-with-ID-var-values-occur-n-times-in-Proc/m-p/414646#M101602</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-19T09:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to overcome with ID var values occur n times in Proc tranpose?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-overcome-with-ID-var-values-occur-n-times-in-Proc/m-p/414669#M101611</link>
      <description>&lt;P&gt;This looks like the right approach.&amp;nbsp; However, we don't really know how many duplicates there might be, or for which exam values they might occur.&amp;nbsp; In order to handle many possible variations, the data preparation needs to take care of additional situations.&amp;nbsp; After creating DAT3:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=dat3;&lt;/P&gt;
&lt;P&gt;by name id exam;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data temp;&lt;/P&gt;
&lt;P&gt;set dat3;&lt;/P&gt;
&lt;P&gt;by name id exam;&lt;/P&gt;
&lt;P&gt;if first.exam then group=1;&lt;/P&gt;
&lt;P&gt;else group + 1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=temp;&lt;/P&gt;
&lt;P&gt;by name id group;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At that point, the final PROC TRANSPOSE in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;'s solution would be appropriate.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Nov 2017 14:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-overcome-with-ID-var-values-occur-n-times-in-Proc/m-p/414669#M101611</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-19T14:34:09Z</dc:date>
    </item>
  </channel>
</rss>

