<?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: Convert Cell value to Column Variables (0,1 dummy) in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Cell-value-to-Column-Variables-0-1-dummy/m-p/39527#M4729</link>
    <description>SAS PROC TRANSPOSE can accomodate your requirement.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Tue, 02 Jun 2009 18:02:58 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-06-02T18:02:58Z</dc:date>
    <item>
      <title>Convert Cell value to Column Variables (0,1 dummy)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Cell-value-to-Column-Variables-0-1-dummy/m-p/39526#M4728</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Instead of keep using the following programming;&lt;BR /&gt;
if diag_flag = 'A04' then Diagflag_A04_Dummy = 1;&lt;BR /&gt;
else Diagflag_A04_Dummy = 0;&lt;BR /&gt;
if diag_flag = 'A41' then Diagflag_A41_Dummy = 1;&lt;BR /&gt;
else Diagflag_A41_Dummy = 0;&lt;BR /&gt;
if diag_flag = 'C16' then Diagflag_C16_Dummy = 1;&lt;BR /&gt;
else Diagflag_C16_Dummy = 0;.....&lt;BR /&gt;
&lt;BR /&gt;
How can I convert my data in column (Diagflag) to multiple Dummy variables, &lt;BR /&gt;
&lt;U&gt;Data currently looking like&lt;/U&gt;&lt;BR /&gt;
Diagflag&lt;BR /&gt;
D12&lt;BR /&gt;
C13&lt;BR /&gt;
Q15&lt;BR /&gt;
D12&lt;BR /&gt;
A14&lt;BR /&gt;
&lt;BR /&gt;
&lt;U&gt;Want outcome&lt;/U&gt; with cell value become column heading and 0,1 as values&lt;BR /&gt;
D12  C13  Q15  A14.....&lt;BR /&gt;
1       0         0    0&lt;BR /&gt;
0       1         0    0&lt;BR /&gt;
0       0         1    0&lt;BR /&gt;
1       0         0    0&lt;BR /&gt;
0       0         0    1</description>
      <pubDate>Tue, 02 Jun 2009 00:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Cell-value-to-Column-Variables-0-1-dummy/m-p/39526#M4728</guid>
      <dc:creator>JChan10</dc:creator>
      <dc:date>2009-06-02T00:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Cell value to Column Variables (0,1 dummy)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Cell-value-to-Column-Variables-0-1-dummy/m-p/39527#M4729</link>
      <description>SAS PROC TRANSPOSE can accomodate your requirement.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 02 Jun 2009 18:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Cell-value-to-Column-Variables-0-1-dummy/m-p/39527#M4729</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-02T18:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Cell value to Column Variables (0,1 dummy)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Cell-value-to-Column-Variables-0-1-dummy/m-p/39528#M4730</link>
      <description>I think the Transpose will put back the actual row observations back to the column but not the 0 and 1.  I just want 0 and 1.&lt;BR /&gt;
&lt;BR /&gt;
For example, under diagflag column, first obsevation is D12, then I would like to have a new column create named as D12 and the value in the first row under column D12 is 1.</description>
      <pubDate>Tue, 02 Jun 2009 21:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Cell-value-to-Column-Variables-0-1-dummy/m-p/39528#M4730</guid>
      <dc:creator>JChan10</dc:creator>
      <dc:date>2009-06-02T21:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Cell value to Column Variables (0,1 dummy)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Cell-value-to-Column-Variables-0-1-dummy/m-p/39529#M4731</link>
      <description>Yes, you will need to carry a numeric variable to be used as an indicator, and use this variable by name in the PROC TRANSPOSE for the VAR statement along with the ID statement as well.  Also code a PREFIX= to get the transposed columns having a defined prefix.  &lt;BR /&gt;
&lt;BR /&gt;
The key here is that you need to take the _N_  SAS-reserved variable (observation number) and assign it to a SAS numeric variable, say called OBSNUM.  And this variable must be called-out in your ID statement so that you get one observation output for each transposed observation -- this approach maintains your vertical perspective.&lt;BR /&gt;
&lt;BR /&gt;
What you will have generated is a new file, transposed with either a 1 or 0, depending on what was present in the input file.&lt;BR /&gt;
&lt;BR /&gt;
Then, you will need to have a DATA step to loop through the transposed variables and if you find a missing value, change it to a zero -- that's better than setting MISSING='0' in my experience.&lt;BR /&gt;
&lt;BR /&gt;
You'll find SAS-hosted product documentation and also supplemental technical and conference papers on various topics, like this one.  I have provided a link at the bottom for one example on PROC TRANSPOSE.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Learn the Basics of Proc Transpose&lt;BR /&gt;
Douglas Zirbel, Wells Fargo and Co., St. Louis, Missouri&lt;BR /&gt;
&lt;A href="http://support.sas.com/resources/papers/proceedings09/060-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/060-2009.pdf&lt;/A&gt;</description>
      <pubDate>Tue, 02 Jun 2009 21:54:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Cell-value-to-Column-Variables-0-1-dummy/m-p/39529#M4731</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-02T21:54:11Z</dc:date>
    </item>
  </channel>
</rss>

