<?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: Manipulating Proc Transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480187#M286594</link>
    <description>&lt;P&gt;Thank you, it looks great so far! However, for some reason, it codes feature as missing variables entirely. Do you know how I can prevent this?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cracker1.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21903iEEA417C4954157C1/image-size/large?v=v2&amp;amp;px=999" role="button" title="cracker1.jpg" alt="cracker1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 21 Jul 2018 21:22:12 GMT</pubDate>
    <dc:creator>Errant</dc:creator>
    <dc:date>2018-07-21T21:22:12Z</dc:date>
    <item>
      <title>Manipulating Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480182#M286592</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset that looks like this. There are indicator variables for the purchase of each brand, for each brand display and each brand feature. There's also the price for each brand in each observation.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="cracker.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21901i8D2B02F61273312A/image-size/large?v=v2&amp;amp;px=999" role="button" title="cracker.jpg" alt="cracker.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The data set that I want looks like. Each subject will be split into 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t;/P&gt;&lt;P&gt;Essentially it's a wide to long transformation and I believe I need to merge the certain variables. So far I've been trying to use proc transpose, in several different ways. One example being :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc transpose data=HW5.crackers_hw5;
   var DisplKeebler  DisplNabisco DisplPrivate DisplSunshine FeatKeebler FeatNabisco FeatPrivate FeatSunshine; 
   by obs KEEBLER NABISCO PRIVATE SUNSHINE;
run;&lt;/PRE&gt;&lt;P&gt;My first question is, how do I merge the indicator variables appropriately? Secondly, what would be the best way to manipulate proc transpose to get this data set?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 20:26:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480182#M286592</guid>
      <dc:creator>Errant</dc:creator>
      <dc:date>2018-07-21T20:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480183#M286593</link>
      <description>&lt;P&gt;I think you will be better off accomplishing the task in a datastep using arrays. e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=obs Purchase Brand Feature Display Price);
  set have;
  array pur(*) PRIVATE SUNSHINE KEEBLER NABISCO;
  array pri(*) PRICEPRIVATE PRICESUNSHINE PRICEKEEBLER PRICENABISCO;
  array fea(*) FeaturePrivate FeatureSunshine FeatureKeebler FeatureNabisco;
  array dis(*) DisplPrivate DisplSunshine DisplKeebler DisplNabisco;
  do i=1 to 4;
    Purchase=pur(i);
    Brand=vname(pur(i));
    Feature=fea(i);
    Display=dis(i);
    Price=pri(i);
    output;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 21:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480183#M286593</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-07-21T21:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480187#M286594</link>
      <description>&lt;P&gt;Thank you, it looks great so far! However, for some reason, it codes feature as missing variables entirely. Do you know how I can prevent this?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cracker1.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21903iEEA417C4954157C1/image-size/large?v=v2&amp;amp;px=999" role="button" title="cracker1.jpg" alt="cracker1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 21:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480187#M286594</guid>
      <dc:creator>Errant</dc:creator>
      <dc:date>2018-07-21T21:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480188#M286595</link>
      <description>&lt;P&gt;Errant, it would sure help if you showed us the code you used.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 21:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480188#M286595</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-21T21:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480189#M286596</link>
      <description>&lt;P&gt;Sorry about that. Essentially, just the same code posted above.&lt;/P&gt;&lt;PRE&gt;data want new (keep=obs Purchase Brand Feature Display Price);
  set crackers;;
  array pur(*) PRIVATE SUNSHINE KEEBLER NABISCO;
  array pri(*) PRICEPRIVATE PRICESUNSHINE PRICEKEEBLER PRICENABISCO;
  array fea(*) FeaturePrivate FeatureSunshine FeatureKeebler FeatureNabisco;
  array dis(*) DisplPrivate DisplSunshine DisplKeebler DisplNabisco;
  do i=1 to 4;
    Purchase=pur(i);
    Brand=vname(pur(i));
    Feature=fea(i);
    Display=dis(i);
    Price=pri(i);
    output;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Jul 2018 21:34:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480189#M286596</guid>
      <dc:creator>Errant</dc:creator>
      <dc:date>2018-07-21T21:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480190#M286597</link>
      <description>&lt;P&gt;So the variables names in the code do not match the variable names in your data set for features, this is easily fixed.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 21:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480190#M286597</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-21T21:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480191#M286598</link>
      <description>&lt;P&gt;I had the wrong variable names for feature. Try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=obs Purchase Brand Feature Display Price);
  set have;
  array pur(*) PRIVATE SUNSHINE KEEBLER NABISCO;
  array pri(*) PRICEPRIVATE PRICESUNSHINE PRICEKEEBLER PRICENABISCO;
  array fea(*) FeatPrivate FeatSunshine FeatKeebler FeatNabisco;
  array dis(*) DisplPrivate DisplSunshine DisplKeebler DisplNabisco;
  do i=1 to 4;
    Purchase=pur(i);
    Brand=vname(pur(i));
    Feature=fea(i);
    Display=dis(i);
    Price=pri(i);
    output;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 21:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480191#M286598</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-07-21T21:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480193#M286599</link>
      <description>Thank you so much, incredibly helpful.</description>
      <pubDate>Sat, 21 Jul 2018 21:55:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manipulating-Proc-Transpose/m-p/480193#M286599</guid>
      <dc:creator>Errant</dc:creator>
      <dc:date>2018-07-21T21:55:26Z</dc:date>
    </item>
  </channel>
</rss>

