<?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: How to create dummy variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables/m-p/490427#M128303</link>
    <description>&lt;P&gt;Hi s_lassen,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your kind help. The first part of the problem is solved. Would you please advise me how to do sub-sampling based on each bidder which will contain observations as shown below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sub-sample I want" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22827iB548EE9132CFF26F/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.jpg" alt="Sub-sample I want" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Sub-sample I want&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22828iBBAF7AC61D925088/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.jpg" alt="3.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;May I request to provide macro codes so that I can get each bidder's trading detail in one run.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Aug 2018 12:01:50 GMT</pubDate>
    <dc:creator>Zakir</dc:creator>
    <dc:date>2018-08-28T12:01:50Z</dc:date>
    <item>
      <title>How to create dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables/m-p/490394#M128291</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a trading data set which contains time, bidder, asker, price and volume&amp;nbsp; variable. The data set looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Data I Have" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22823iE6C5D6252DA05393/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.jpg" alt="Data I Have" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Data I Have&lt;/span&gt;&lt;/span&gt;&lt;BR /&gt;I want to create dummy variables based on unique bidder. The idea is if a bidder appears in the bidder column, dummy variable should take 0 and if the same bidder appears anywhere in the asking column, dummy variable should take 1. If write the code, it looks:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want; set have;&lt;BR /&gt;if bidder="ByronHal" then dum1=0; if asker="ByronHal" then dum1=1;&lt;BR /&gt;if bidder="EdyssaPal" then dum2=0; if asker="EdyssaPal" then dum2=1;&lt;BR /&gt;...........&lt;/P&gt;&lt;P&gt;if bidder="ZacharyBra" then dum9=0; if asker="ZacharyBra" then dum9=1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;The problem for this code is manual. I need to look manually who are bidders and type their names. Is there any way to do this by the program!! I mean let the program decide how many unique bidders are there and generate dummies. Finally, can I get sub samples for each bidder from that file. The final sub samples for each bidder should look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sub Sample for bidder1&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sun Sample1" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22825iC2E4B43C51A0A937/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.jpg" alt="Sun Sample1" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Sun Sample1&lt;/span&gt;&lt;/span&gt;&lt;BR /&gt;sub sample for bidder2&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sub Sample2" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22826i725A4CF715FC6CF4/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.jpg" alt="Sub Sample2" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Sub Sample2&lt;/span&gt;&lt;/span&gt;&lt;BR /&gt;&amp;nbsp;Let me thank you in advance for&amp;nbsp;helping!!&lt;/P&gt;&lt;P&gt;Zakir&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 09:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables/m-p/490394#M128291</guid>
      <dc:creator>Zakir</dc:creator>
      <dc:date>2018-08-28T09:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables/m-p/490396#M128293</link>
      <description>&lt;P&gt;I'd create formats from the names, set one new variable using that format, and then transpose to the wide format with the multiple dummies.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please supply example data in a readily usable format (data step with datalines).&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 10:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables/m-p/490396#M128293</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-28T10:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables/m-p/490399#M128295</link>
      <description>&lt;P&gt;You can do it something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input bidder $ asker $;
cards;
a b
a c
b a
c d
;run;


proc sql;
  create table brokers as select monotonic() as id,broker
  from(select bidder as broker from have union select asker as broker from have);
  %let n=&amp;amp;sqlobs;
  create index broker on brokers(broker);
quit;

data dummy;
  set have;
  array dummies (*) dum1-dum&amp;amp;n;
  set brokers(rename=(broker=asker)) key=asker/unique;
  dummies(id)=1;
  set brokers(rename=(broker=bidder)) key=bidder/unique;
  dummies(id)=0;
  drop id;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But what are you goint to use that for? It is very bad programming practice to put data (broker IDs) into variable names.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 10:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables/m-p/490399#M128295</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-08-28T10:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables/m-p/490427#M128303</link>
      <description>&lt;P&gt;Hi s_lassen,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your kind help. The first part of the problem is solved. Would you please advise me how to do sub-sampling based on each bidder which will contain observations as shown below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sub-sample I want" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22827iB548EE9132CFF26F/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.jpg" alt="Sub-sample I want" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Sub-sample I want&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22828iBBAF7AC61D925088/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.jpg" alt="3.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;May I request to provide macro codes so that I can get each bidder's trading detail in one run.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 12:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables/m-p/490427#M128303</guid>
      <dc:creator>Zakir</dc:creator>
      <dc:date>2018-08-28T12:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables/m-p/490600#M128390</link>
      <description>&lt;P&gt;And the rule(s) for creating the subsample are what if any?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 19:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables/m-p/490600#M128390</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-28T19:44:25Z</dc:date>
    </item>
  </channel>
</rss>

