<?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: Reshaping Data Set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11378#M1038</link>
    <description>use var statement. check proc transpose documents for correct sytax and requirements. you may need to sort by location if you need to use by in proc transpose. you will get a column _name_ after transposing, with values of 'q1','q2', etc. you may extract the numeric part from that by substr.&lt;BR /&gt;
seems that you actually have 10 instead of 3 questions? you may want to use array then. format will help translating the categoric values.</description>
    <pubDate>Tue, 03 Nov 2009 20:22:31 GMT</pubDate>
    <dc:creator>abdullala</dc:creator>
    <dc:date>2009-11-03T20:22:31Z</dc:date>
    <item>
      <title>Reshaping Data Set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11375#M1035</link>
      <description>I have four variables:&lt;BR /&gt;
Location (x,y,z), q1, q2, and q3 (where each line is a different individual).&lt;BR /&gt;
q1,q2, and q3 are categorical variables (Disagree, Agree, Strongly Agree).&lt;BR /&gt;
I would like to create a data set with the following variables:&lt;BR /&gt;
Location, Question (numeric variable ranging from 1-10), Disagree, Agree, Strongly_Agree&lt;BR /&gt;
where the data set would look like this:&lt;BR /&gt;
Location  Question  Agree Disagree Strongly_Agree&lt;BR /&gt;
x             1                1     0           0&lt;BR /&gt;
x             1                0     1          0&lt;BR /&gt;
x             2                0     0          1&lt;BR /&gt;
x             2                1     0          0&lt;BR /&gt;
x             3                1     0          0&lt;BR /&gt;
x            3                0      1           0&lt;BR /&gt;
where each line is a different individual (no individual identifier is needed).&lt;BR /&gt;
If a person agreed with a certain question they get a 1 for Agree and a zero for Disagree and Strong_Agree.&lt;BR /&gt;
Thank you.</description>
      <pubDate>Tue, 03 Nov 2009 19:07:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11375#M1035</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-11-03T19:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Reshaping Data Set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11376#M1036</link>
      <description>I assume you mean q1,q2,q3 are 3 questions, with categoric values disagree, agree or stronly.&lt;BR /&gt;
1.create 3 new variable to represent your category for q1,q2,q3. sicne there are only 3 categories, you may use agree='100',disagree='010',strongly='001'.&lt;BR /&gt;
2.use proc transpose to get a verticle layout of the original data, for the 3 new variables.&lt;BR /&gt;
3.parse new values into 3 category vars, ie. agree, disagree, strongly, eg. by using substr.</description>
      <pubDate>Tue, 03 Nov 2009 19:42:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11376#M1036</guid>
      <dc:creator>abdullala</dc:creator>
      <dc:date>2009-11-03T19:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Reshaping Data Set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11377#M1037</link>
      <description>This looks like it could work.&lt;BR /&gt;
I'm having some trouble setting up the proc transpose statement, though.&lt;BR /&gt;
I did this part:&lt;BR /&gt;
agree='100',disagree='010',strongly='001'&lt;BR /&gt;
How do I write the proc transpose so that q1, q2, and q3 are all in one column named question (where question=1,2,3)?&lt;BR /&gt;
Thank you.</description>
      <pubDate>Tue, 03 Nov 2009 20:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11377#M1037</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-11-03T20:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Reshaping Data Set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11378#M1038</link>
      <description>use var statement. check proc transpose documents for correct sytax and requirements. you may need to sort by location if you need to use by in proc transpose. you will get a column _name_ after transposing, with values of 'q1','q2', etc. you may extract the numeric part from that by substr.&lt;BR /&gt;
seems that you actually have 10 instead of 3 questions? you may want to use array then. format will help translating the categoric values.</description>
      <pubDate>Tue, 03 Nov 2009 20:22:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11378#M1038</guid>
      <dc:creator>abdullala</dc:creator>
      <dc:date>2009-11-03T20:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Reshaping Data Set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11379#M1039</link>
      <description>PROC TRANSPOSE converts "vertical" to "horizontal", not the other way.  To accomplish the objective of taking a file as you have shown, it will take a Data step approach.  The SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website has SAS-hosted documentation and supplemental technical and conference reference material.  You can use the SEARCH facility at the website or use a Google advanced search argument as shown below:&lt;BR /&gt;
&lt;BR /&gt;
vertical transpose sas dataset site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
234-31: The TRANSPOSE Procedure or How to Turn It Around&lt;BR /&gt;
Janet Stuelpner, Left Hand Computing, Inc., New Canaan, CT&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi31/234-31.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi31/234-31.pdf&lt;/A&gt;</description>
      <pubDate>Tue, 03 Nov 2009 22:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11379#M1039</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-11-03T22:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Reshaping Data Set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11380#M1040</link>
      <description>proc transpose does convert vertical to horizontal and vise versa. it worked perfectly for this purpose.&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
input Location $ q1 $ q2 $ q3 $;&lt;BR /&gt;
cards;&lt;BR /&gt;
x Disagree Agree Stronly&lt;BR /&gt;
y  Agree  Disagree Stronly &lt;BR /&gt;
x Stronly Disagree Disagree  &lt;BR /&gt;
z Stronly Stronly Disagree  &lt;BR /&gt;
x Disagree Stronly Agree  &lt;BR /&gt;
z Stronly Stronly Disagree   &lt;BR /&gt;
x  Agree Disagree Stronly &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data a;&lt;BR /&gt;
 set a;&lt;BR /&gt;
 n=_n_;&lt;BR /&gt;
run;&lt;BR /&gt;
proc transpose data=a out=b;&lt;BR /&gt;
var q1 q2 q3;&lt;BR /&gt;
by n location;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 04 Nov 2009 14:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11380#M1040</guid>
      <dc:creator>abdullala</dc:creator>
      <dc:date>2009-11-04T14:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reshaping Data Set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11381#M1041</link>
      <description>The key to a horizontal to vertical transpose with PROC TRANSPOSE as you have coded is the necessary evil, unique KEY.  In your example.  n=_n_;&lt;BR /&gt;
&lt;BR /&gt;
My data, usually has a unique key so the coding a necessary evil is usually unnecessary.  You should consider a data step view in for this task.</description>
      <pubDate>Wed, 04 Nov 2009 16:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11381#M1041</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-11-04T16:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Reshaping Data Set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11382#M1042</link>
      <description>you are absolutely right. the original author said he had a subject ID variable which he didn't need, otherwise that can be used as the unique key. I created the variable n=_n_ to omit the sorting procedure. all I wanted to illustrate in this example is that proc transpose does convert horizontal to vertical. happy SAS coding!</description>
      <pubDate>Wed, 04 Nov 2009 16:27:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshaping-Data-Set/m-p/11382#M1042</guid>
      <dc:creator>abdullala</dc:creator>
      <dc:date>2009-11-04T16:27:43Z</dc:date>
    </item>
  </channel>
</rss>

