<?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: Long to Wide format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846494#M36893</link>
    <description>&lt;P&gt;Please see if this link is what you're trying to do:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.oarc.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/" target="_blank"&gt;https://stats.oarc.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 27 Nov 2022 11:05:04 GMT</pubDate>
    <dc:creator>tarheel13</dc:creator>
    <dc:date>2022-11-27T11:05:04Z</dc:date>
    <item>
      <title>Long to Wide format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846402#M36877</link>
      <description>&lt;P&gt;New to Sas and I am trying to figure out how to format the data from long to wide.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data muscatine_wide; by id; 
set hw7.muscatine; 
array y[3] o1 o2 o3;
array age[3] a1 a2 a3;
y[occasion] = obese;
retain o1 -o2; 
a[occasion] = age;
if first.id = 1 then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the error code I am getting. However, I don't know if the sas code (above) is accomplishing what I am trying to do.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;1    libname hw7 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Homework 7';
NOTE: Libref HW7 was successfully assigned as follows:
      Engine:        V9
      Physical Name: \\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Homework 7
2    run;
3    data glow_combined;
4    set hw7.glow1
5    hw7.glow2
6    hw7.glow3
7    hw7.glow4
8    hw7.glow5
9    hw7.glow6;
10   run;

NOTE: There were 107 observations read from the data set HW7.GLOW1.
NOTE: There were 90 observations read from the data set HW7.GLOW2.
NOTE: There were 65 observations read from the data set HW7.GLOW3.
NOTE: There were 36 observations read from the data set HW7.GLOW4.
NOTE: There were 120 observations read from the data set HW7.GLOW5.
NOTE: There were 82 observations read from the data set HW7.GLOW6.
NOTE: The data set WORK.GLOW_COMBINED has 500 observations and 9 variables.
NOTE: DATA statement used (Total process time):
      real time           0.15 seconds
      cpu time            0.03 seconds


11   data glow_combined;
12   set hw7.glow1(in= glow1)
13   hw7.glow2 (in=glow2)
14   hw7.glow3 (in=glow3)
15   hw7.glow4 (in=glow4)
16   hw7.glow5 (in=glow5)
17   hw7.glow6 (in=glow6);
18   if glow1 then site_id  = 1;
19   if glow2 then site_id  = 2;
20   if glow3 then site_id = 3;
21   if glow4 then site_id = 4;
22   if glow5 then site_id = 5;
23   if glow6 then site_id = 6;
24   run;

NOTE: There were 107 observations read from the data set HW7.GLOW1.
NOTE: There were 90 observations read from the data set HW7.GLOW2.
NOTE: There were 65 observations read from the data set HW7.GLOW3.
NOTE: There were 36 observations read from the data set HW7.GLOW4.
NOTE: There were 120 observations read from the data set HW7.GLOW5.
NOTE: There were 82 observations read from the data set HW7.GLOW6.
NOTE: The data set WORK.GLOW_COMBINED has 500 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.12 seconds
      cpu time            0.03 seconds


25   data glow_cleaned;
26   set glow_combined;
27   array miss[3] age weight height;
28   do i = 1 to 3;
29       if miss [i] = 999 then miss[i] = .;
30       drop i;
31   end;
32   run;

NOTE: There were 500 observations read from the data set WORK.GLOW_COMBINED.
NOTE: The data set WORK.GLOW_CLEANED has 500 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


33   data glow;
34   set glow_cleaned;
35   array miss_char[3] momfrac raterisk priorfrac;
36   do i = 1 to 3;
37    if miss_char[i] in ('NA') then miss_char[i] = " ";
38    end;
39    drop i;
40    run;

NOTE: There were 500 observations read from the data set WORK.GLOW_CLEANED.
NOTE: The data set WORK.GLOW has 500 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


41   data glow;
42   set glow_cleaned;
43   bmi = weight/((height/100)**2);
44   if age&amp;lt;=65 and (bmi&amp;lt;18 or bmi&amp;gt;25) then age_bmicat=1;
45   else if age&amp;lt;=65 and (18 &amp;lt;= bmi &amp;lt;= 25) then age_bmicat = 2;
46   if age&amp;gt;65 and (bmi&amp;lt;25 or bmi&amp;gt;30)then age_bmicat=3;
47   else if age&amp;gt;65 and (25 &amp;lt;= bmi &amp;lt;= 30) then age_bmicat=4;
48   run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      81 at 43:13    100 at 43:22
NOTE: There were 500 observations read from the data set WORK.GLOW_CLEANED.
NOTE: The data set WORK.GLOW has 500 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


49   proc sort data=glow; by descending priorfrac descending fracture;

NOTE: There were 500 observations read from the data set WORK.GLOW.
NOTE: The data set WORK.GLOW has 500 observations and 12 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


50   proc freq data=glow order=data; where priorfrac ne 'NA';
51   table priorfrac*fracture/chisq relrisk;
52   run;

NOTE: Writing HTML Body file: sashtml.htm
NOTE: There were 400 observations read from the data set WORK.GLOW.
      WHERE priorfrac not = 'NA';
NOTE: PROCEDURE FREQ used (Total process time):
      real time           0.43 seconds
      cpu time            0.31 seconds


53   proc logistic data=glow descending; where priorfrac ne 'NA';
54   class priorfrac (param=ref ref="No");
55   model fracture = priorfrac/clodds=wald;
56   run;

NOTE: PROC LOGISTIC is modeling the probability that fracture='1'.
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: There were 400 observations read from the data set WORK.GLOW.
      WHERE priorfrac not = 'NA';
NOTE: PROCEDURE LOGISTIC used (Total process time):
      real time           0.87 seconds
      cpu time            0.40 seconds


57   proc logistic data=glow descending;
58   class age_bmicat (param=ref ref='1');
59   model fracture = age_bmicat/clodds=wald;

NOTE: PROC LOGISTIC is modeling the probability that fracture='1'.
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: There were 500 observations read from the data set WORK.GLOW.
NOTE: PROCEDURE LOGISTIC used (Total process time):
      real time           41.10 seconds
      cpu time            1.70 seconds


60   data muscatine_wide(keep=(id o1 o2 o3 a1 a2 a3 gender));
                              -
                              214
                              23
ERROR 214-322: Variable name ( is not valid.

ERROR 23-7: Invalid value for the KEEP option.

61   by id;
ERROR: No SET, MERGE, UPDATE, or MODIFY statement is present.
62   set hw7.muscatine;
63   array y[3] o1 o2 o3;
           -
           124
ERROR 124-185: The variable y has already been defined.

64   array age[3] a1 a2 a3;
           ---
           124
ERROR 124-185: The variable age has already been defined.

65   y[occasion] = obese;
ERROR: Undeclared array referenced: Y.
ERROR: Variable Y has not been declared as an array.
66   retain o1 -o2;
67   a[occasion] = age;
ERROR: Undeclared array referenced: a.
ERROR: Variable a has not been declared as an array.
68   if first.id = 1 then delete;
69   run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 Nov 2022 02:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846402#M36877</guid>
      <dc:creator>MisterJenn</dc:creator>
      <dc:date>2022-11-26T02:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Long to Wide format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846405#M36878</link>
      <description>&lt;P&gt;The log tells you the first things that are wrong. Fix them and repost the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;60   data muscatine_wide(keep=(id o1 o2 o3 a1 a2 a3 gender));
                              -
                              214
                              23
&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;ERROR 214-322: Variable name ( is not valid.&lt;/STRONG&gt;&lt;/FONT&gt;

ERROR 23-7: Invalid value for the KEEP option.

61   by id;
&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;ERROR: No SET, MERGE, UPDATE, or MODIFY statement is present.&lt;/FONT&gt;&lt;/STRONG&gt;
62   set hw7.muscatine;&lt;/PRE&gt;
&lt;UL&gt;
&lt;LI&gt;The KEEP variable list should not be in parenthesis within the KEEP data set option. Remove the extra parenthesis&lt;/LI&gt;
&lt;LI&gt;There is no SET statement so there is no input data set&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without the raw data it's hard to see if the code is correct but you're on the right path with some missing components.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;Missing retain for the age variables&lt;BR /&gt;&lt;BR /&gt;Use FIRST. and CALL MISSING to reset variables at the start of each ID group&lt;BR /&gt;&lt;BR /&gt;Use LAST. to output only the last record for each ID group, keeping the wide version of variables&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI-SPOILER&gt;
&lt;P&gt;Transposing data tutorials:&lt;BR /&gt;Long to Wide:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Nov 2022 03:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846405#M36878</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-26T03:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Long to Wide format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846410#M36879</link>
      <description>&lt;P&gt;What do you intend to do with the wide data? If it's for display, PROC REPORT will be the way to go.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Nov 2022 07:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846410#M36879</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-26T07:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Long to Wide format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846413#M36880</link>
      <description>&lt;P&gt;There are few benefits and lots of drawbacks to converting a data set from long to wide. Without a good reason, I would avoid doing this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Especially if you want a report, then do as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; says and use PROC REPORT, and then you don't have to convert the data from long to wide (and by avoiding doing this work, you avoid one of the drawbacks of converting long to wide). Example: &lt;A href="https://communities.sas.com/t5/SAS-Programming/Proc-transpose-with-multiple-var/m-p/846310#M334585" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Proc-transpose-with-multiple-var/m-p/846310#M334585&lt;/A&gt;&amp;nbsp;Example 2:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/ODS-and-Base-Reporting/format-all-column-names-that-are-similar/m-p/682619#M24419" target="_blank"&gt;https://communities.sas.com/t5/ODS-and-Base-Reporting/format-all-column-names-that-are-similar/m-p/682619#M24419&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Nov 2022 12:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846413#M36880</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-26T12:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Long to Wide format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846448#M36888</link>
      <description>&lt;P&gt;I have to do this for a class assignment.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Nov 2022 23:24:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846448#M36888</guid>
      <dc:creator>MisterJenn</dc:creator>
      <dc:date>2022-11-26T23:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Long to Wide format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846459#M36889</link>
      <description>&lt;P&gt;So the whole issue is transposing the muscatine dataset. Please supply example data for this dataset in a data step with datalines, and the expected output.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2022 08:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846459#M36889</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-27T08:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Long to Wide format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846494#M36893</link>
      <description>&lt;P&gt;Please see if this link is what you're trying to do:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.oarc.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/" target="_blank"&gt;https://stats.oarc.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2022 11:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846494#M36893</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-11-27T11:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Long to Wide format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846498#M36894</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/435394"&gt;@MisterJenn&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have to do this for a class assignment.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So, what does the assignment ask you to do with this wide data set, once you create it??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your teacher is teaching you an inefficient way to do things. Please remember that long data sets are easier to work than wide data sets when the class ends and you have to do this for an actual job.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2022 11:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846498#M36894</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-27T11:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Long to Wide format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846510#M36895</link>
      <description>We are using this data set to conduct a logistic regression analysis</description>
      <pubDate>Sun, 27 Nov 2022 17:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846510#M36895</guid>
      <dc:creator>MisterJenn</dc:creator>
      <dc:date>2022-11-27T17:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Long to Wide format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846518#M36896</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/435394"&gt;@MisterJenn&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;We are using this data set to conduct a logistic regression analysis&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Okay, you still haven't shown us the data set, but this COULD be (but still might not be) one of the few good reasons to convert long into wide.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2022 22:05:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Long-to-Wide-format/m-p/846518#M36896</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-27T22:05:55Z</dc:date>
    </item>
  </channel>
</rss>

