<?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: Transforming data long to wide, issue with code in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Transforming-data-long-to-wide-issue-with-code/m-p/740062#M35956</link>
    <description>&lt;P&gt;Don't create DATA step variables with the same names as your arrays:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data long;
set mental ;
array Avg_hrs_sleep_month(0:2) Avg_hrs_sleep_month0-Avg_hrs_sleep_month2;
array hrs_of_sleep_yest(0:2) hrs_of_sleep_yest0-hrs_of_sleep_yest2;

*Insomnia0 Insomnia1 Insomnia2 see_yourself_6month0 see_yourself_6month1 see_yourself_6month2;
do time=0 to 2;
Avg_hrs_sleep_mth = Avg_hrs_sleep_month(time);
hrs_of_sleep_yday = hrs_of_sleep_yest(time);
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 09 May 2021 21:25:30 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2021-05-09T21:25:30Z</dc:date>
    <item>
      <title>Transforming data long to wide, issue with code</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Transforming-data-long-to-wide-issue-with-code/m-p/740060#M35955</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to transform this data from wide to long but kept having issues:&lt;/P&gt;
&lt;P&gt;data long;&lt;BR /&gt;set mental ;&lt;BR /&gt;array Avg_hrs_sleep_month(0:2) Avg_hrs_sleep_month0-Avg_hrs_sleep_month2;&lt;BR /&gt;array hrs_of_sleep_yest(0:2) hrs_of_sleep_yest0-hrs_of_sleep_yest2;&lt;BR /&gt;&lt;BR /&gt;*Insomnia0 Insomnia1 Insomnia2 see_yourself_6month0 see_yourself_6month1 see_yourself_6month2;&lt;BR /&gt;do time=0 to 2;&lt;BR /&gt;Avg_hrs_sleep_month = Avg_hrs_sleep_month(time);&lt;BR /&gt;hrs_of_sleep_yest= hrs_of_sleep_yest(time);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;215 data long;&lt;BR /&gt;216 set mental ;&lt;BR /&gt;217 array Avg_hrs_sleep_month(0:2) Avg_hrs_sleep_month0-Avg_hrs_sleep_month2;&lt;BR /&gt;218 array hrs_of_sleep_yest(0:2) hrs_of_sleep_yest0-hrs_of_sleep_yest2;&lt;BR /&gt;219&lt;BR /&gt;220 *Insomnia0 Insomnia1 Insomnia2 see_yourself_6month0 see_yourself_6month1 see_yourself_6month2&lt;BR /&gt;220! ;&lt;BR /&gt;221 do time=0 to 2;&lt;BR /&gt;&lt;STRONG&gt;222 Avg_hrs_sleep_month = Avg_hrs_sleep_month(time);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ERROR: Illegal reference to the array Avg_hrs_sleep_month.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;223 hrs_of_sleep_yest= hrs_of_sleep_yest(time);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ERROR: Illegal reference to the array hrs_of_sleep_yest.&lt;/STRONG&gt;&lt;BR /&gt;224 output;&lt;BR /&gt;225 end;&lt;BR /&gt;226 run;&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.LONG may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 46 variables.&lt;BR /&gt;WARNING: Data set WORK.LONG was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 May 2021 20:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Transforming-data-long-to-wide-issue-with-code/m-p/740060#M35955</guid>
      <dc:creator>desireatem</dc:creator>
      <dc:date>2021-05-09T20:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming data long to wide, issue with code</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Transforming-data-long-to-wide-issue-with-code/m-p/740062#M35956</link>
      <description>&lt;P&gt;Don't create DATA step variables with the same names as your arrays:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data long;
set mental ;
array Avg_hrs_sleep_month(0:2) Avg_hrs_sleep_month0-Avg_hrs_sleep_month2;
array hrs_of_sleep_yest(0:2) hrs_of_sleep_yest0-hrs_of_sleep_yest2;

*Insomnia0 Insomnia1 Insomnia2 see_yourself_6month0 see_yourself_6month1 see_yourself_6month2;
do time=0 to 2;
Avg_hrs_sleep_mth = Avg_hrs_sleep_month(time);
hrs_of_sleep_yday = hrs_of_sleep_yest(time);
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 May 2021 21:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Transforming-data-long-to-wide-issue-with-code/m-p/740062#M35956</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-05-09T21:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming data long to wide, issue with code</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Transforming-data-long-to-wide-issue-with-code/m-p/740063#M35957</link>
      <description>&lt;P&gt;Thank you, this has put me in a state of complete frustration. Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 09 May 2021 21:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Transforming-data-long-to-wide-issue-with-code/m-p/740063#M35957</guid>
      <dc:creator>desireatem</dc:creator>
      <dc:date>2021-05-09T21:29:34Z</dc:date>
    </item>
  </channel>
</rss>

