<?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: Modification to proc transpose output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Modification-to-proc-transpose-output/m-p/679782#M205304</link>
    <description>thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;!</description>
    <pubDate>Thu, 27 Aug 2020 15:53:30 GMT</pubDate>
    <dc:creator>luch25</dc:creator>
    <dc:date>2020-08-27T15:53:30Z</dc:date>
    <item>
      <title>Modification to proc transpose output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modification-to-proc-transpose-output/m-p/679777#M205301</link>
      <description>&lt;P&gt;I've written code using proc transpose (below), but it needs a modification that I can't quite figure out.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input id location $;
cards;
1 A
1 B
1 C
2 A
3 A
3 B
;

proc sql;
  create table want1 as 
  select distinct id, location from a;
run;

 proc transpose data = want1 out=want1a(drop =_name_) prefix = location_;
  by id;
  id location;
  var location;
   run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The resulting output gives me the character value for the location (A, B, C) for each location_X variable. In other words, I get:&lt;/P&gt;&lt;P&gt;id location_A location_B location_C&lt;/P&gt;&lt;P&gt;1 A B C&lt;/P&gt;&lt;P&gt;2 A&lt;/P&gt;&lt;P&gt;3 A B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The information is correct, but instead of a character value, I wanted a binary indicator 1/0. So essentially, I'm looking for:&lt;/P&gt;&lt;P&gt;id location_A location_B location_C&lt;/P&gt;&lt;P&gt;1 1 1 0&lt;/P&gt;&lt;P&gt;2 1 0 0&lt;/P&gt;&lt;P&gt;3 1 1 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to modify my proc transpose code to get this? Or another way to do this?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 15:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modification-to-proc-transpose-output/m-p/679777#M205301</guid>
      <dc:creator>luch25</dc:creator>
      <dc:date>2020-08-27T15:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Modification to proc transpose output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modification-to-proc-transpose-output/m-p/679778#M205302</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input id location $;
cards;
1 A
1 B
1 C
2 A
3 A
3 B
;

proc sql;
  create table want1 as 
  select distinct id, location, 1 as indicator from a;
run;

 proc transpose data = want1 out=want1a(drop =_name_) prefix = location_;
  by id;
  id location;
  var indicator;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Add an indicator variable. You'll have to do a second step to add in the 0, but another way could be to look at a dummy variable type calculation instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/343488"&gt;@luch25&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I've written code using proc transpose (below), but it needs a modification that I can't quite figure out.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input id location $;
cards;
1 A
1 B
1 C
2 A
3 A
3 B
;

proc sql;
  create table want1 as 
  select distinct id, location from a;
run;

 proc transpose data = want1 out=want1a(drop =_name_) prefix = location_;
  by id;
  id location;
  var location;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The resulting output gives me the character value for the location (A, B, C) for each location_X variable. In other words, I get:&lt;/P&gt;
&lt;P&gt;id location_A location_B location_C&lt;/P&gt;
&lt;P&gt;1 A B C&lt;/P&gt;
&lt;P&gt;2 A&lt;/P&gt;
&lt;P&gt;3 A B&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The information is correct, but instead of a character value, I wanted a binary indicator 1/0. So essentially, I'm looking for:&lt;/P&gt;
&lt;P&gt;id location_A location_B location_C&lt;/P&gt;
&lt;P&gt;1 1 1 0&lt;/P&gt;
&lt;P&gt;2 1 0 0&lt;/P&gt;
&lt;P&gt;3 1 1 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to modify my proc transpose code to get this? Or another way to do this?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 15:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modification-to-proc-transpose-output/m-p/679778#M205302</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-27T15:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Modification to proc transpose output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modification-to-proc-transpose-output/m-p/679782#M205304</link>
      <description>thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;!</description>
      <pubDate>Thu, 27 Aug 2020 15:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modification-to-proc-transpose-output/m-p/679782#M205304</guid>
      <dc:creator>luch25</dc:creator>
      <dc:date>2020-08-27T15:53:30Z</dc:date>
    </item>
  </channel>
</rss>

