<?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 Proc transpose - wide to long (many variables) in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22008#M4736</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are a number of ways to do it.&amp;nbsp; Since I always have a difficult time remembering the various proc transpose options, and none of my code is EVER production code, I usually address such a problem in the following manner (Note: the type WAS rather small, thus I may have misspelled some of the variable names):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=DiaryID name--IOS);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array names(3) p1name p2name p3name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array person(3,8) p1gender--p1IOS&lt;/P&gt;&lt;P&gt;&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; p2gender--p2IOS&lt;/P&gt;&lt;P&gt;&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; p3gender--p3IOS;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to 3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name=names(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gender=person(i,1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; age=person(i,2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ortinter=person(i,3);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Similar=person(i,4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; judgment=person(i,5);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; defense=person(i,6);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; argument=person(i,7);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IOS=person(i,8);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 02 Oct 2011 19:43:46 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2011-10-02T19:43:46Z</dc:date>
    <item>
      <title>Proc transpose - wide to long (many variables)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22005#M4733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to transpose my data to get it into univariate form for proc mixed analyses.&lt;/P&gt;&lt;P&gt;I have multi-level data: One person reported on measures for 5 target people.&amp;nbsp; I have an ID for the person who is completing the questionnaire. Each target person is named person1, person2, person3, etc.&lt;/P&gt;&lt;P&gt;Currently the data is all on one line. The variables are named such that they indicate what person they belong to (e.g. p1similar). There are approximately 8 variables for each target person.&lt;/P&gt;&lt;P&gt;How should my code look so that I can shape my data to have 5 lines of data for the respondent, corresponding to the data for each target person?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Id-respondent1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Person1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var var&amp;nbsp; var var&amp;nbsp; var&lt;/P&gt;&lt;P&gt;Id-respondent1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Person2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var var&amp;nbsp; var var&amp;nbsp; var&lt;/P&gt;&lt;P&gt;Id-respondent1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Person 3&amp;nbsp;&amp;nbsp;&amp;nbsp; var&amp;nbsp; var&amp;nbsp; var var&amp;nbsp; var&lt;/P&gt;&lt;P&gt;Id-respondent2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Person1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var var&amp;nbsp; var var&amp;nbsp; var&lt;/P&gt;&lt;P&gt;Id-respondent2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Person2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var var&amp;nbsp; var var&amp;nbsp; var&lt;/P&gt;&lt;P&gt;Id-respondent2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Person 3&amp;nbsp;&amp;nbsp;&amp;nbsp; var&amp;nbsp; var&amp;nbsp; var var&amp;nbsp; var&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe this is the way that my data should look in order to run proc mixed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have thus far only been able to find examples with a single variable, and I cannot figure out how to translate it to more than one variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would really appreciate any help from all the smart SAS users out there!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Camilla&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Oct 2011 18:08:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22005#M4733</guid>
      <dc:creator>coverup</dc:creator>
      <dc:date>2011-10-02T18:08:56Z</dc:date>
    </item>
    <item>
      <title>Proc transpose - wide to long (many variables)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22006#M4734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will get the best answer if you provide an example, in the form of a datastep, that shows what your data currently looks like.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Oct 2011 18:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22006#M4734</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-02T18:33:26Z</dc:date>
    </item>
    <item>
      <title>Proc transpose - wide to long (many variables)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22007#M4735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I normally read my data in from an excel sheet. Here is a small snippet of what it looks like currently. Since the data is on one long row/line of data, I think it would be too much to paste in here. I have taken an excerpt of 4 people reporting on two people.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;﻿﻿&lt;IMG alt="sas help proc transpose 2.PNG" class="jive-image-thumbnail jive-image" onclick="" src="https://communities.sas.com/legacyfs/online/1193_sas help proc transpose 2.PNG" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure if this is even visible (it's probably too small). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;an example of the variables are:&lt;/P&gt;&lt;P&gt;DiaryID&amp;nbsp; P1name&amp;nbsp; P1Gender&amp;nbsp; P1Age P1Similar&amp;nbsp; P1Judgment&amp;nbsp; P1defensive&amp;nbsp; p1IOS&amp;nbsp; p2name&amp;nbsp; p2gender&amp;nbsp; p2age&amp;nbsp; p2similar&amp;nbsp; p2judgment&amp;nbsp; p2defensive p2IOS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DiaryID is the respondent ID. P1name/P2name is the number of the target person being reported on (out of 5).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is that of any help?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Oct 2011 19:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22007#M4735</guid>
      <dc:creator>coverup</dc:creator>
      <dc:date>2011-10-02T19:03:09Z</dc:date>
    </item>
    <item>
      <title>Proc transpose - wide to long (many variables)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22008#M4736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are a number of ways to do it.&amp;nbsp; Since I always have a difficult time remembering the various proc transpose options, and none of my code is EVER production code, I usually address such a problem in the following manner (Note: the type WAS rather small, thus I may have misspelled some of the variable names):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=DiaryID name--IOS);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array names(3) p1name p2name p3name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array person(3,8) p1gender--p1IOS&lt;/P&gt;&lt;P&gt;&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; p2gender--p2IOS&lt;/P&gt;&lt;P&gt;&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; p3gender--p3IOS;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to 3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name=names(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gender=person(i,1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; age=person(i,2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ortinter=person(i,3);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Similar=person(i,4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; judgment=person(i,5);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; defense=person(i,6);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; argument=person(i,7);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IOS=person(i,8);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Oct 2011 19:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22008#M4736</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-02T19:43:46Z</dc:date>
    </item>
    <item>
      <title>Proc transpose - wide to long (many variables)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22009#M4737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For your case, It is not difficulty as long as you make sure they have the same number of variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data temp;
infile datalines truncover;
input DiaryID $ @;
input (Pname&amp;nbsp; PGender&amp;nbsp; PAge PSimilar&amp;nbsp; PJudgment&amp;nbsp; Pdefensive&amp;nbsp; pIOS) ($) @;
do while(not missing(Pname));
&amp;nbsp; output;
&amp;nbsp; input (Pname&amp;nbsp; PGender&amp;nbsp; PAge PSimilar&amp;nbsp; PJudgment&amp;nbsp; Pdefensive&amp;nbsp; pIOS) ($) @;
end;
input;
datalines; 
001 Peter 4 5 7 8 3 8 Arthur 2 3 5 7 8 6 
002 Patrick 4 5 7 8 3 8 Cynthia 2 3 5 7 8 6
;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Oct 2011 08:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22009#M4737</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-10-03T08:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose - wide to long (many variables)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22010#M4738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ... if your data are in a spreadsheet and you have 5 people reporting within each row,&lt;/P&gt;&lt;P&gt;you can try reading the data directly from the spreadsheet.&amp;nbsp; Using the variable names&lt;/P&gt;&lt;P&gt;that you posted (6 variables within each person) and assuming the data are in SHEET1 ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;libname x 'z:\yourdata.xls';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;data new;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;set x.'sheet1'n;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;length name $10;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;array nm(5) p1name p2name p3name p4name p5name;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;array va(*) p1gender-numeric-p5ios;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;array vb(6) gender age similar judgment defensive ios;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;do j = 1 to 5;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; name = nm(j);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;do k = 1 to 6;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; vb(k) = va((j-1)*6 + k);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;output;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;keep diaryid name gender age similar judgment defensive ios;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;libname x clear;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Oct 2011 16:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-transpose-wide-to-long-many-variables/m-p/22010#M4738</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2011-10-03T16:42:13Z</dc:date>
    </item>
  </channel>
</rss>

