<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/820587#M323907</link>
    <description>&lt;P&gt;I need to transpose (wide to long) a dataset. 49 variables: Id, resp1-resp16, err1-err16, item1-item16. resp is string(character) err and item are numeric. So it seems like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc transpose data=lec1 out=leclong; by studyid;&lt;BR /&gt;var resp1-resp16 lecerr1-lecerr16 item1-item16; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ought to work fine although i have never done this in sas (spss many times both ways). First of all is sas capable of doing this? I've read the documentation and also Cody and i notice that they don't show a multivariable example, which seems strange because proc mixed may well require transposing multiple variables. Or, is my syntax wrong?&lt;/P&gt;&lt;P&gt;The expected output dataset would have 4 columns with 16 rows per studyid value. I get a result but it's botched up. unusable.&lt;/P&gt;&lt;P&gt;Thanks, Gene Maguin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jun 2022 20:12:23 GMT</pubDate>
    <dc:creator>emaguin</dc:creator>
    <dc:date>2022-06-27T20:12:23Z</dc:date>
    <item>
      <title>proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/820587#M323907</link>
      <description>&lt;P&gt;I need to transpose (wide to long) a dataset. 49 variables: Id, resp1-resp16, err1-err16, item1-item16. resp is string(character) err and item are numeric. So it seems like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc transpose data=lec1 out=leclong; by studyid;&lt;BR /&gt;var resp1-resp16 lecerr1-lecerr16 item1-item16; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ought to work fine although i have never done this in sas (spss many times both ways). First of all is sas capable of doing this? I've read the documentation and also Cody and i notice that they don't show a multivariable example, which seems strange because proc mixed may well require transposing multiple variables. Or, is my syntax wrong?&lt;/P&gt;&lt;P&gt;The expected output dataset would have 4 columns with 16 rows per studyid value. I get a result but it's botched up. unusable.&lt;/P&gt;&lt;P&gt;Thanks, Gene Maguin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 20:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/820587#M323907</guid>
      <dc:creator>emaguin</dc:creator>
      <dc:date>2022-06-27T20:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/820588#M323908</link>
      <description>&lt;P&gt;PROC TRANSPOSE will not handle that directly, especially if you have mixed numeric and character variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it is trivial to do it yourself.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data leclong;
  set lec1;
  array _r resp1-resp16;
  array _l lecerr1-lecerr16;
  array _i item1-item16;
  do index=1 to 16;
   resp = _r[index];
   lecerr = _l[index];
   item = _i[index];
   output;
  end;
  drop resp1-resp16 lecerr1-lecerr16 item1-item16; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jun 2022 20:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/820588#M323908</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-27T20:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/841373#M332687</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;Very helpful script, very glad I found it.&lt;/P&gt;&lt;P&gt;However, it works for me only for character variables.&lt;/P&gt;&lt;P&gt;When I have only numerical variables (not mixed with character once) and try to transform them, I have an error:&lt;/P&gt;&lt;P&gt;ERROR: Too many variables defined for the dimension(s) specified for the array d.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;array d {40} drugdose:;&lt;BR /&gt;do index=1 to 40;&lt;BR /&gt;drugdoses = d[index];&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;What did I miss?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Val&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 20:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/841373#M332687</guid>
      <dc:creator>valtina1</dc:creator>
      <dc:date>2022-10-28T20:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/841382#M332689</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436650"&gt;@valtina1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Tom,&lt;/P&gt;
&lt;P&gt;Very helpful script, very glad I found it.&lt;/P&gt;
&lt;P&gt;However, it works for me only for character variables.&lt;/P&gt;
&lt;P&gt;When I have only numerical variables (not mixed with character once) and try to transform them, I have an error:&lt;/P&gt;
&lt;P&gt;ERROR: Too many variables defined for the dimension(s) specified for the array d.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;array d {40} drugdose:;&lt;BR /&gt;do index=1 to 40;&lt;BR /&gt;drugdoses = d[index];&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;What did I miss?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Val&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why did you tell the data step compiler there were 40 variables whose names start with DRUGDOSE when there aren't 40 of them?&lt;/P&gt;
&lt;P&gt;Why did you tell it ANY number at all? The data step compiler will count how many variables are in the list you provided it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array d  drugdose:;
do index=1 to dim(d);
  drugdoses = d[index];
  output;
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Oct 2022 20:45:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/841382#M332689</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-28T20:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/842356#M333087</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I tried everything... with missing data and w/o missing, with categorical IDs and w/o IDs - it doesn't work.&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input drugdose1 drugdose2 drugdose3;&lt;BR /&gt;datalines;&lt;BR /&gt;30 30 0.12&lt;BR /&gt;0.2 0.2 0.2&lt;BR /&gt;0.2 0.2 0.2&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;array d drugdose:;&lt;BR /&gt;do index=1 to dim(d);&lt;BR /&gt;drugdoses = d[index];&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;... don't know what I have missed...&lt;/P&gt;&lt;P&gt;For categorical variables it is perfect.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 16:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/842356#M333087</guid>
      <dc:creator>valtina1</dc:creator>
      <dc:date>2022-11-03T16:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/842358#M333089</link>
      <description>&lt;P&gt;Sorry, please, ignore my last post.&lt;/P&gt;&lt;P&gt;The last example works perfectly. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 16:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose/m-p/842358#M333089</guid>
      <dc:creator>valtina1</dc:creator>
      <dc:date>2022-11-03T16:18:21Z</dc:date>
    </item>
  </channel>
</rss>

