<?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 creat dummy variables for a series of cont. var. by using macro in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-creat-dummy-variables-for-a-series-of-cont-var-by-using/m-p/523467#M4625</link>
    <description>&lt;P&gt;Thank&amp;nbsp;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892" target="_self"&gt;&lt;SPAN class="login-bold"&gt;PaigeMiller&lt;/SPAN&gt;&lt;/A&gt; and&amp;nbsp;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461" target="_self"&gt;&lt;SPAN class="login-bold"&gt;mkeintz&lt;/SPAN&gt;&lt;/A&gt; for your prompt responses.&lt;/P&gt;&lt;P&gt;I can't believe I can get help immediately.&lt;/P&gt;&lt;P&gt;The example provide by &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461" target="_self"&gt;&lt;SPAN class="login-bold"&gt;mkeintz&lt;/SPAN&gt;&lt;/A&gt; completely solved my question.&lt;/P&gt;&lt;P&gt;And it's so elegant. (although I still don't understand a part of the program, it works well.)&lt;/P&gt;&lt;P&gt;Thank yo so much for the kind help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wish you a Merry Christmas &amp;amp; Happy New Year !!&lt;/P&gt;&lt;P&gt;Cheers &amp;nbsp;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://communities.sas.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Dec 2018 14:49:26 GMT</pubDate>
    <dc:creator>RobertWang</dc:creator>
    <dc:date>2018-12-25T14:49:26Z</dc:date>
    <item>
      <title>How to creat dummy variables for a series of cont. var. by using macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-creat-dummy-variables-for-a-series-of-cont-var-by-using/m-p/523415#M4614</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a dataset which consists of over 100 continuous variables.&lt;/P&gt;&lt;P&gt;What I want to do is to creat corresponding dummy variables in the same dataset according to their medians.&lt;/P&gt;&lt;P&gt;Because of the large number of variables, I'd like to do it by means of %macro.&lt;/P&gt;&lt;P&gt;In the attached, I first input a dataset as an example and provide some codes (syntax) that I've tried.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have basic ability in programming, but not&amp;nbsp;in coding macro syntax at all.&lt;/P&gt;&lt;P&gt;Could you please do me a favor?&amp;nbsp; I apprecite your efforts and help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Dec 2018 17:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-creat-dummy-variables-for-a-series-of-cont-var-by-using/m-p/523415#M4614</guid>
      <dc:creator>RobertWang</dc:creator>
      <dc:date>2018-12-24T17:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to creat dummy variables for a series of cont. var. by using macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-creat-dummy-variables-for-a-series-of-cont-var-by-using/m-p/523418#M4615</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;What I want to do is to create corresponding dummy variables in the same dataset according to their medians.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What happens after you find the medians of each variable? What is the next step?&amp;nbsp;How do you go from medians to dummy variables?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I doubt a macro is needed here, but the answer really depends on what you do with the medians.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Dec 2018 17:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-creat-dummy-variables-for-a-series-of-cont-var-by-using/m-p/523418#M4615</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-12-24T17:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to creat dummy variables for a series of cont. var. by using macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-creat-dummy-variables-for-a-series-of-cont-var-by-using/m-p/523423#M4617</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/252476"&gt;@RobertWang&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think you need a macro.&amp;nbsp; What you really need is&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;A list of variables to pass through proc means processing (i.e.&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;VARS TGFB2--COH1_208834;&lt;/STRONG&gt; in your case - NOTE THE DOUBLE DASH)&lt;/LI&gt;
&lt;LI&gt;Tell the proc means to generate medians and assign them to a corresponding list of names.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Run a data step comparing the original list of variables to the corresponding list of medians, generating yet another corresponding list of dummy variables.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Here's an example using sashelp.class:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sashelp.class noprint ;
  vars age -numeric- weight;
  output out=meds (drop=_type_ _freq_) median= p50= / autoname;
run;

data want;
  set sashelp.class ;
  if _n_=1 then set meds;
  array vars {*} age--weight ;
  array meds {*} age_median--weight_median;
  array p50  {*} age_p50--weight_p50;
  do i=1 to dim(vars);
    p50{i}=ifn(vars{i}=.,.,vars{i}&amp;gt;meds{i});
  end;
  drop age_median--weight_median i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The vars statement tells proc means to generate stats on all the numeric variables from age (on the left) through weight (on the right).&lt;/LI&gt;
&lt;LI&gt;The output statement tells sas to generate two stats for each variable: median and percentile 50.&amp;nbsp; Yes, they are the same stat, but the use of the autoname option tells sas to name the new variables as&amp;nbsp; age_median age_height age_weight and age_p50 height_p50 and weight_p50.&amp;nbsp; This will be handy in the following data step.&lt;/LI&gt;
&lt;LI&gt;The data step defines three "synchronized" arrays.&amp;nbsp; Each element of the P50 array will be recalculated based on whether the original variable element is greater than its corresponding median.&lt;/LI&gt;
&lt;LI&gt;Not the "if _n_=1 then set ..." statement is a way to read the median and p50's and not have them reset to missing in subsequent data step iterations.&amp;nbsp; I.e. they are "retained".&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 24 Dec 2018 17:58:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-creat-dummy-variables-for-a-series-of-cont-var-by-using/m-p/523423#M4617</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-24T17:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to creat dummy variables for a series of cont. var. by using macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-creat-dummy-variables-for-a-series-of-cont-var-by-using/m-p/523467#M4625</link>
      <description>&lt;P&gt;Thank&amp;nbsp;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892" target="_self"&gt;&lt;SPAN class="login-bold"&gt;PaigeMiller&lt;/SPAN&gt;&lt;/A&gt; and&amp;nbsp;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461" target="_self"&gt;&lt;SPAN class="login-bold"&gt;mkeintz&lt;/SPAN&gt;&lt;/A&gt; for your prompt responses.&lt;/P&gt;&lt;P&gt;I can't believe I can get help immediately.&lt;/P&gt;&lt;P&gt;The example provide by &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461" target="_self"&gt;&lt;SPAN class="login-bold"&gt;mkeintz&lt;/SPAN&gt;&lt;/A&gt; completely solved my question.&lt;/P&gt;&lt;P&gt;And it's so elegant. (although I still don't understand a part of the program, it works well.)&lt;/P&gt;&lt;P&gt;Thank yo so much for the kind help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wish you a Merry Christmas &amp;amp; Happy New Year !!&lt;/P&gt;&lt;P&gt;Cheers &amp;nbsp;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://communities.sas.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Dec 2018 14:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-creat-dummy-variables-for-a-series-of-cont-var-by-using/m-p/523467#M4625</guid>
      <dc:creator>RobertWang</dc:creator>
      <dc:date>2018-12-25T14:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to creat dummy variables for a series of cont. var. by using macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-creat-dummy-variables-for-a-series-of-cont-var-by-using/m-p/523560#M4642</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/252476"&gt;@RobertWang&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which part of my program that you don't understand yet?&amp;nbsp; I can edit my answer to clarify.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Dec 2018 17:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-creat-dummy-variables-for-a-series-of-cont-var-by-using/m-p/523560#M4642</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-26T17:25:25Z</dc:date>
    </item>
  </channel>
</rss>

