<?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 A problem with proc transpose in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/A-problem-with-proc-transpose/m-p/44090#M11623</link>
    <description>Dear All,&lt;BR /&gt;
&lt;BR /&gt;
First of all I need to thank everyone here whos posts I've used to help me learn more about SAS. At the moment I am building some applications to help me create tables out of a dataset. However, a problem with proc transpose arose on which I need your help.&lt;BR /&gt;
&lt;BR /&gt;
Let's say that I've made this crossed table (results over 2 questions), where there is no-one who awnsered question 1 with a 2 AND question 2 with a 2. I get this table:&lt;BR /&gt;
&lt;BR /&gt;
Q1   Q2   freq&lt;BR /&gt;
1     1       2&lt;BR /&gt;
1     2       2 &lt;BR /&gt;
1     3       3&lt;BR /&gt;
2     1       2 &lt;BR /&gt;
2     3       1&lt;BR /&gt;
3     1       2&lt;BR /&gt;
3     2       2&lt;BR /&gt;
3     3       3&lt;BR /&gt;
&lt;BR /&gt;
Using:&lt;BR /&gt;
&lt;BR /&gt;
proc transpose data = ... out = ... prefix = vari; &lt;BR /&gt;
BY Q1;&lt;BR /&gt;
var freq;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I get this table:&lt;BR /&gt;
&lt;BR /&gt;
Q2   vari1          vari2            vari3&lt;BR /&gt;
1        2               2                3&lt;BR /&gt;
2        2               1                 .&lt;BR /&gt;
3        2               2                3&lt;BR /&gt;
&lt;BR /&gt;
Where the "." should actually be on (Q2 = 2, vari2); instead the 1 from (Q2=2,vari3) is placed there.&lt;BR /&gt;
&lt;BR /&gt;
How can I overcome this problem? Is there a simple command for it? Or should I go back to the proc freq I used to create the first table and solve the problem there?&lt;BR /&gt;
&lt;BR /&gt;
Any help would be welcome! Have a nice day</description>
    <pubDate>Fri, 05 Sep 2008 09:21:08 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-09-05T09:21:08Z</dc:date>
    <item>
      <title>A problem with proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-problem-with-proc-transpose/m-p/44090#M11623</link>
      <description>Dear All,&lt;BR /&gt;
&lt;BR /&gt;
First of all I need to thank everyone here whos posts I've used to help me learn more about SAS. At the moment I am building some applications to help me create tables out of a dataset. However, a problem with proc transpose arose on which I need your help.&lt;BR /&gt;
&lt;BR /&gt;
Let's say that I've made this crossed table (results over 2 questions), where there is no-one who awnsered question 1 with a 2 AND question 2 with a 2. I get this table:&lt;BR /&gt;
&lt;BR /&gt;
Q1   Q2   freq&lt;BR /&gt;
1     1       2&lt;BR /&gt;
1     2       2 &lt;BR /&gt;
1     3       3&lt;BR /&gt;
2     1       2 &lt;BR /&gt;
2     3       1&lt;BR /&gt;
3     1       2&lt;BR /&gt;
3     2       2&lt;BR /&gt;
3     3       3&lt;BR /&gt;
&lt;BR /&gt;
Using:&lt;BR /&gt;
&lt;BR /&gt;
proc transpose data = ... out = ... prefix = vari; &lt;BR /&gt;
BY Q1;&lt;BR /&gt;
var freq;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I get this table:&lt;BR /&gt;
&lt;BR /&gt;
Q2   vari1          vari2            vari3&lt;BR /&gt;
1        2               2                3&lt;BR /&gt;
2        2               1                 .&lt;BR /&gt;
3        2               2                3&lt;BR /&gt;
&lt;BR /&gt;
Where the "." should actually be on (Q2 = 2, vari2); instead the 1 from (Q2=2,vari3) is placed there.&lt;BR /&gt;
&lt;BR /&gt;
How can I overcome this problem? Is there a simple command for it? Or should I go back to the proc freq I used to create the first table and solve the problem there?&lt;BR /&gt;
&lt;BR /&gt;
Any help would be welcome! Have a nice day</description>
      <pubDate>Fri, 05 Sep 2008 09:21:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-problem-with-proc-transpose/m-p/44090#M11623</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-05T09:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-problem-with-proc-transpose/m-p/44091#M11624</link>
      <description>Please review your own code.  The SAS PROC PRINT output you show in your post could not have been generated by the PROC TRANSPOSE code that you provided.  There would not be a Q2 variable output by TRANSPOSE, unless you supply that variable in the BY statement list.  You asking for assistance and guidance while not truly revealing the code and results that relate to one another.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 05 Sep 2008 14:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-problem-with-proc-transpose/m-p/44091#M11624</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-09-05T14:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-problem-with-proc-transpose/m-p/44092#M11625</link>
      <description>Hi Vince.&lt;BR /&gt;
I think that you are lacking an ID statement in your Transpose procedure. This will allow SAS to connect newly created variables to Q2 values, instead of just re-arranging values by Q1 values as it currently does.&lt;BR /&gt;
Could you try this code and tell us if this is what you are looking for ?&lt;BR /&gt;
(I assumed that the output table you posted add the Q1 variable as the first column, and not "Q2", as Scott pointed out.)&lt;BR /&gt;
[pre]&lt;BR /&gt;
DATA test ;&lt;BR /&gt;
	INPUT Q1 Q2 freq ;&lt;BR /&gt;
CARDS ;&lt;BR /&gt;
1 1 2&lt;BR /&gt;
1 2 2 &lt;BR /&gt;
1 3 3&lt;BR /&gt;
2 1 2 &lt;BR /&gt;
2 3 1&lt;BR /&gt;
3 1 2&lt;BR /&gt;
3 2 2&lt;BR /&gt;
3 3 3&lt;BR /&gt;
;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
PROC TRANSPOSE DATA = test OUT = test2 ;&lt;BR /&gt;
	VAR freq ;&lt;BR /&gt;
	BY q1 ;&lt;BR /&gt;
	ID q2 ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Regards&lt;BR /&gt;
Olivier</description>
      <pubDate>Mon, 08 Sep 2008 09:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-problem-with-proc-transpose/m-p/44092#M11625</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2008-09-08T09:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-problem-with-proc-transpose/m-p/44093#M11626</link>
      <description>You are right, the by statement had Q2 instead of Q1.&lt;BR /&gt;
&lt;BR /&gt;
proc transpose data = ... out = ... prefix = vari; &lt;BR /&gt;
BY Q2;&lt;BR /&gt;
var freq;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
is my correct code. I was simplifying the names of the variables before posting it here, and I made an error.</description>
      <pubDate>Mon, 08 Sep 2008 09:50:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-problem-with-proc-transpose/m-p/44093#M11626</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-08T09:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-problem-with-proc-transpose/m-p/44094#M11627</link>
      <description>Oliver,&lt;BR /&gt;
&lt;BR /&gt;
That did the trick, thank you! And Scott, I will be more carefull with my next post, thank you.</description>
      <pubDate>Mon, 08 Sep 2008 09:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-problem-with-proc-transpose/m-p/44094#M11627</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-08T09:55:03Z</dc:date>
    </item>
  </channel>
</rss>

