<?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: proc transpose replicating rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-replicating-rows/m-p/827420#M326839</link>
    <description>&lt;P&gt;It might help to show what you expect the output to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: place an actual .&amp;nbsp; for "missing values".&lt;/P&gt;
&lt;P&gt;The forum software will reformat text pasted into the message window and likely your "getting" data set example is intended to show missing values but since I have to believe your source had spaces the result after the forum finished with the pasted text is not very clear.&lt;/P&gt;
&lt;P&gt;Also, if you open a text box using the &amp;lt;/&amp;gt; icon that appears above the message window to paste text the window doesn't reformat the text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your result does not include the GROUP variable and that variable on the By statement in Proc Transpose means that output rows are studentid group combinations. The example input means that there is only one Score for each group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think that you do not want the GROUP variable on the BY statement in Proc Transpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See if this does what you expect:&lt;/P&gt;
&lt;PRE&gt;data have;
   input Studentid $ itemscore itemid $;
datalines;
00s1 1 it1
00s1 1 it2
00s1 0 it3
00s1 2 it4
00a2 0 it1
00a2 1 it2
00a2 3 it3
;
proc sort data=have;
   by studentid itemid;
run;
data temp;
   set have;
   by StudentId;
   if first.studentid then group=1;
   else group+1;
run;
proc sort data=temp;
   by studentid group;
run;

proc transpose data=temp out=trans;
   by studentid ;
   var itemscore;
   id itemid;
run;&lt;/PRE&gt;
&lt;P&gt;Please note the DATA step to provide example data and the appearance of the text box around the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Aug 2022 19:25:35 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-08-05T19:25:35Z</dc:date>
    <item>
      <title>proc transpose replicating rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-replicating-rows/m-p/827410#M326834</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have data set such as below. I am using proc transpose to put items in the columns and students in the rows and there will be item scores where items and students match. I am not getting any error but i am getting a data set below. Here is my code. I have no idea why this is happening.Thank you&lt;/P&gt;
&lt;P&gt;Have:&lt;/P&gt;
&lt;P&gt;Studentid itemscore itemid&lt;/P&gt;
&lt;P&gt;00s1 1 it1&lt;/P&gt;
&lt;P&gt;00s1 1 it2&lt;/P&gt;
&lt;P&gt;00s1 0 it3&lt;/P&gt;
&lt;P&gt;00s1 2 it4&lt;/P&gt;
&lt;P&gt;00a2 0 it1&lt;/P&gt;
&lt;P&gt;00a2 1 it2&lt;/P&gt;
&lt;P&gt;00a2 3 it3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Getting:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;it1 it2 it3 it4&lt;/P&gt;
&lt;P&gt;00s1 1&lt;/P&gt;
&lt;P&gt;00s1&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;00s1&amp;nbsp; &amp;nbsp;0&lt;/P&gt;
&lt;P&gt;00s1&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;00a2 0&lt;/P&gt;
&lt;P&gt;00a2&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;00s2&amp;nbsp; &amp;nbsp;3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=Cleanest_mat04;
by     StudentID ;
run;
data temp;
set Cleanest_mat04;
by    StudentID   ;
if first.StudentID then group=1;
else group+1;
run;
proc sort data=temp;
by     StudentID group;
run;

Proc Transpose data = temp out= tr_fully_mat04_n  ;
var itemscore;
by    StudentID group;
id itemid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2022 17:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-replicating-rows/m-p/827410#M326834</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2022-08-05T17:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose replicating rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-replicating-rows/m-p/827420#M326839</link>
      <description>&lt;P&gt;It might help to show what you expect the output to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: place an actual .&amp;nbsp; for "missing values".&lt;/P&gt;
&lt;P&gt;The forum software will reformat text pasted into the message window and likely your "getting" data set example is intended to show missing values but since I have to believe your source had spaces the result after the forum finished with the pasted text is not very clear.&lt;/P&gt;
&lt;P&gt;Also, if you open a text box using the &amp;lt;/&amp;gt; icon that appears above the message window to paste text the window doesn't reformat the text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your result does not include the GROUP variable and that variable on the By statement in Proc Transpose means that output rows are studentid group combinations. The example input means that there is only one Score for each group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think that you do not want the GROUP variable on the BY statement in Proc Transpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See if this does what you expect:&lt;/P&gt;
&lt;PRE&gt;data have;
   input Studentid $ itemscore itemid $;
datalines;
00s1 1 it1
00s1 1 it2
00s1 0 it3
00s1 2 it4
00a2 0 it1
00a2 1 it2
00a2 3 it3
;
proc sort data=have;
   by studentid itemid;
run;
data temp;
   set have;
   by StudentId;
   if first.studentid then group=1;
   else group+1;
run;
proc sort data=temp;
   by studentid group;
run;

proc transpose data=temp out=trans;
   by studentid ;
   var itemscore;
   id itemid;
run;&lt;/PRE&gt;
&lt;P&gt;Please note the DATA step to provide example data and the appearance of the text box around the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2022 19:25:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-replicating-rows/m-p/827420#M326839</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-08-05T19:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose replicating rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-replicating-rows/m-p/827422#M326840</link>
      <description>&lt;P&gt;Oh my Goodness! deleting group helped. Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2022 18:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-replicating-rows/m-p/827422#M326840</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2022-08-05T18:41:14Z</dc:date>
    </item>
  </channel>
</rss>

