<?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: proc transpose issue in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38586#M9926</link>
    <description>Thank you Data _null_.&lt;BR /&gt;
&lt;BR /&gt;
Do you know if there is an option to automatically convert missing values to 0? Suppose I have the original dataset like this -&lt;BR /&gt;
&lt;BR /&gt;
Male    A 10&lt;BR /&gt;
Female  A 5&lt;BR /&gt;
Male    B 10&lt;BR /&gt;
&lt;BR /&gt;
When I transpose this I get &lt;BR /&gt;
      A  B&lt;BR /&gt;
Male  10 10&lt;BR /&gt;
Female 5 .&lt;BR /&gt;
&lt;BR /&gt;
I want the Female-B cell to be converted to 0 rather than missing value. The reason behind this is that I have several rows that are being transposed to columns.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
saspert.

Message was edited by: saspert</description>
    <pubDate>Tue, 29 Mar 2011 19:53:44 GMT</pubDate>
    <dc:creator>saspert</dc:creator>
    <dc:date>2011-03-29T19:53:44Z</dc:date>
    <item>
      <title>proc transpose issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38584#M9924</link>
      <description>Hello,&lt;BR /&gt;
I am trying to transpose this dataset &lt;BR /&gt;
Type                       RLTN        PARTICIPANTS&lt;BR /&gt;
Distribution Center	0	4&lt;BR /&gt;
Distribution Center	1	2&lt;BR /&gt;
Headquarters	0	8&lt;BR /&gt;
Headquarters	1	3&lt;BR /&gt;
Retail Store	0	4&lt;BR /&gt;
Retail Store	1	2&lt;BR /&gt;
&lt;BR /&gt;
to this -&lt;BR /&gt;
Type                         0                1&lt;BR /&gt;
Distribution Center	4	2&lt;BR /&gt;
Headquarters	8	3&lt;BR /&gt;
Retail Store	4	2&lt;BR /&gt;
&lt;BR /&gt;
using this code -&lt;BR /&gt;
&lt;BR /&gt;
PROC TRANSPOSE DATA=COMP OUT=COMP_TR &lt;BR /&gt;
(RENAME=(0=PART_EMPLOYEE 1=PART_SPOUSES)) ;&lt;BR /&gt;
BY TYPE;&lt;BR /&gt;
ID RLTN;&lt;BR /&gt;
VAR  participants;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
My issue is that I dont have a valid Rename option because the field names in the transposed dataset are numeric. Is there an automatic way of doing it? &lt;BR /&gt;
&lt;BR /&gt;
The only other option I see is to change 0 and 1 to Employee and Spouse before the transpose. I am looking if there is a way to avoid that.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
saspert</description>
      <pubDate>Fri, 25 Mar 2011 20:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38584#M9924</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2011-03-25T20:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38585#M9925</link>
      <description>For ID variables that don't produce SAS names PROC TRANSPOSE adds _ to the value, see docs for details.&lt;BR /&gt;
&lt;BR /&gt;
So your just need to modify your RENAME option.  I would use the method in the second TRANSPOSE with FORMAT for RLTN.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data COMP;&lt;BR /&gt;
   input Type &amp;amp;$16. RLTN PARTICIPANTS;&lt;BR /&gt;
   cards;&lt;BR /&gt;
Distribution Center  0 4&lt;BR /&gt;
Distribution Center  1 2&lt;BR /&gt;
Headquarters  0 8&lt;BR /&gt;
Headquarters  1 3&lt;BR /&gt;
Retail Store  0 4&lt;BR /&gt;
Retail Store  1 2&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
PROC TRANSPOSE DATA=COMP OUT=COMP_TR &lt;BR /&gt;
(RENAME=(_0=PART_EMPLOYEE _1=PART_SPOUSES)) ;&lt;BR /&gt;
BY TYPE;&lt;BR /&gt;
ID RLTN;&lt;BR /&gt;
VAR participants;&lt;BR /&gt;
RUN;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
   value rltn 0='PartEmployee' 1='PartSpouses';&lt;BR /&gt;
   run;&lt;BR /&gt;
      &lt;BR /&gt;
PROC TRANSPOSE DATA=COMP OUT=COMP_TR(drop=_name_); &lt;BR /&gt;
   BY TYPE; &lt;BR /&gt;
   ID RLTN;&lt;BR /&gt;
   VAR participants;&lt;BR /&gt;
   format rltn rltn.;&lt;BR /&gt;
   RUN;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Sat, 26 Mar 2011 11:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38585#M9925</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-03-26T11:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38586#M9926</link>
      <description>Thank you Data _null_.&lt;BR /&gt;
&lt;BR /&gt;
Do you know if there is an option to automatically convert missing values to 0? Suppose I have the original dataset like this -&lt;BR /&gt;
&lt;BR /&gt;
Male    A 10&lt;BR /&gt;
Female  A 5&lt;BR /&gt;
Male    B 10&lt;BR /&gt;
&lt;BR /&gt;
When I transpose this I get &lt;BR /&gt;
      A  B&lt;BR /&gt;
Male  10 10&lt;BR /&gt;
Female 5 .&lt;BR /&gt;
&lt;BR /&gt;
I want the Female-B cell to be converted to 0 rather than missing value. The reason behind this is that I have several rows that are being transposed to columns.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
saspert.

Message was edited by: saspert</description>
      <pubDate>Tue, 29 Mar 2011 19:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38586#M9926</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2011-03-29T19:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38587#M9927</link>
      <description>PROC STDIZE is pretty easy.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data test;&lt;BR /&gt;
   input gender $ id $ y;&lt;BR /&gt;
   cards;&lt;BR /&gt;
Male A 10&lt;BR /&gt;
Female A 5&lt;BR /&gt;
Male B 10&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc transpose out=tall;&lt;BR /&gt;
   by id;&lt;BR /&gt;
   var y;&lt;BR /&gt;
   id gender;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc stdize out=zeroed reponly missing=0;&lt;BR /&gt;
   var _numeric_;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 30 Mar 2011 16:41:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38587#M9927</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-03-30T16:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38588#M9928</link>
      <description>Great ! Thank you Data _null_. Proc STDIZE is new to me. It will suit my purpose (even though I am not familiar with it &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; ).&lt;BR /&gt;
&lt;BR /&gt;
To your suggestion of using _0 and _1, I am finding using the Prefix option may save me some programming time. I was not familiar with the prefix option until I started researching. But thank you for your suggestion.&lt;BR /&gt;
&lt;BR /&gt;
I have a related issue. There are no errors but I keep getting the warning that some of the drop variables are never referenced -&lt;BR /&gt;
&lt;BR /&gt;
113        PROC TRANSPOSE DATA=COUNT OUT=COUNT_TR (DROP=_LABEL_ _NAME_) PREFIX=COUNT ;&lt;BR /&gt;
114        BY TYPE;&lt;BR /&gt;
115        ID RELATIONSHIP;&lt;BR /&gt;
116        VAR COUNT;&lt;BR /&gt;
117        RUN;&lt;BR /&gt;
&lt;BR /&gt;
WARNING: The variable _LABEL_ in the DROP, KEEP, or RENAME list has never been referenced.

Message was edited by: saspert</description>
      <pubDate>Wed, 30 Mar 2011 17:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38588#M9928</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2011-03-30T17:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38589#M9929</link>
      <description>The _LABEL_ variable is only created by PROC TRANSPOSE if there are variable labels in the input data set for a variable listed in the VAR statement.  &lt;BR /&gt;
&lt;BR /&gt;
If none of those variables have labels, _LABEL_ is not created and therefore cannot be dropped. Removing _LABEL_ from the DROP= option would get rid of the warning. &lt;BR /&gt;
&lt;BR /&gt;
If, for some reason, you must leave _LABEL_ in the DROP= option, you would get the same effect by adding a LABEL statement in the the PROC TRANSPOSE step, specifying any non-blank label for any variable in your VAR statement. The _LABEL_ column will be created, then dropped. A bit odd, but no harm, no foul.&lt;BR /&gt;
&lt;BR /&gt;
-Warren Repole, SAS</description>
      <pubDate>Wed, 30 Mar 2011 21:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38589#M9929</guid>
      <dc:creator>WarrenR_SAS</dc:creator>
      <dc:date>2011-03-30T21:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38590#M9930</link>
      <description>Hi Warren,&lt;BR /&gt;
Thank you for your suggestion. The reason I had drop= _label_ is because the _label_ field shows up in the resulting transposed dataset. Now if I remove the _label_ from the drop = list, the warning goes away but I see the field in the tranposed dataset.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
saspert</description>
      <pubDate>Wed, 30 Mar 2011 23:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-issue/m-p/38590#M9930</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2011-03-30T23:44:32Z</dc:date>
    </item>
  </channel>
</rss>

