<?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 Converting Wide to long  with two sets of variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-Wide-to-long-with-two-sets-of-variables/m-p/493531#M129832</link>
    <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with 4 dependent variables, 6 independent variables and 9 covariates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each combination of dependent and independent variable, I wish to run a model with the specific independent variables alongside the covariates (let's ignore the significance level issue for now). In order to avoid "copy+paste" of the same procedure 24 times, I was thinking to transpose my dataset to long format and use the by statement, I'll be more specific:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="111.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23091iE947B58725F0AA95/image-size/large?v=v2&amp;amp;px=999" role="button" title="111.PNG" alt="111.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want it like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="222.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23092i5F59CA8D40421F1B/image-size/large?v=v2&amp;amp;px=999" role="button" title="222.PNG" alt="222.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I can run a procedure such as GLM and do it "by DV, IV".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know how to use&lt;STRONG&gt; PROC TRANSPOSE&lt;/STRONG&gt; when I have one set of variables which I want to transpose from wide to long. But two...can't figure out how to do it. I wish to avoid the dirty work of doing set and where 24 times. Is there a way to do it ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any assistance will be most appreciated !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Fri, 07 Sep 2018 15:58:05 GMT</pubDate>
    <dc:creator>BlueNose</dc:creator>
    <dc:date>2018-09-07T15:58:05Z</dc:date>
    <item>
      <title>Converting Wide to long  with two sets of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Wide-to-long-with-two-sets-of-variables/m-p/493531#M129832</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with 4 dependent variables, 6 independent variables and 9 covariates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each combination of dependent and independent variable, I wish to run a model with the specific independent variables alongside the covariates (let's ignore the significance level issue for now). In order to avoid "copy+paste" of the same procedure 24 times, I was thinking to transpose my dataset to long format and use the by statement, I'll be more specific:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="111.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23091iE947B58725F0AA95/image-size/large?v=v2&amp;amp;px=999" role="button" title="111.PNG" alt="111.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want it like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="222.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23092i5F59CA8D40421F1B/image-size/large?v=v2&amp;amp;px=999" role="button" title="222.PNG" alt="222.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I can run a procedure such as GLM and do it "by DV, IV".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know how to use&lt;STRONG&gt; PROC TRANSPOSE&lt;/STRONG&gt; when I have one set of variables which I want to transpose from wide to long. But two...can't figure out how to do it. I wish to avoid the dirty work of doing set and where 24 times. Is there a way to do it ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any assistance will be most appreciated !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 15:58:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Wide-to-long-with-two-sets-of-variables/m-p/493531#M129832</guid>
      <dc:creator>BlueNose</dc:creator>
      <dc:date>2018-09-07T15:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Wide to long  with two sets of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Wide-to-long-with-two-sets-of-variables/m-p/493546#M129841</link>
      <description>&lt;P&gt;Since it's wide to long, two arrays within a data step is straightforward enough.&lt;/P&gt;
&lt;P&gt;Are the indexes different though? That may be problematic to make it a long data set, or you'll have missing values for those observations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

array _dv(*) dv1-dv4;
array _iv(*) iv1-iv6;

do i=1 to dim(_dv);*will only go to 4!;
dv=_dv(i);
iv=_iv(i);
output;
end;&lt;BR /&gt;&lt;BR /&gt;run;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Sep 2018 16:34:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Wide-to-long-with-two-sets-of-variables/m-p/493546#M129841</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-07T16:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Wide to long  with two sets of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Wide-to-long-with-two-sets-of-variables/m-p/493603#M129869</link>
      <description>&lt;P&gt;Thank you !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will it work if I have more IV's than DV's ? The loop runs until 4 only.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 19:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Wide-to-long-with-two-sets-of-variables/m-p/493603#M129869</guid>
      <dc:creator>BlueNose</dc:creator>
      <dc:date>2018-09-07T19:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Wide to long  with two sets of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Wide-to-long-with-two-sets-of-variables/m-p/493606#M129870</link>
      <description>&lt;P&gt;What do you want to happen to those rows? You can add a condition but you need to decide if you want to set them to missing, carry forward? The logic depends a bit on what you're doing in the next steps and need for those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1533"&gt;@BlueNose&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will it work if I have more IV's than DV's ? The loop runs until 4 only.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 19:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Wide-to-long-with-two-sets-of-variables/m-p/493606#M129870</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-07T19:45:17Z</dc:date>
    </item>
  </channel>
</rss>

