<?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 write a macro to dichotomize categories in the data step for 14 survey questions? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496300#M131212</link>
    <description>Did you look at using arrays as mentioned? The tutorial is pretty straightforward.</description>
    <pubDate>Mon, 17 Sep 2018 16:37:21 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-09-17T16:37:21Z</dc:date>
    <item>
      <title>How to write a macro to dichotomize categories in the data step for 14 survey questions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496258#M131196</link>
      <description>&lt;P&gt;I have a pretest survey and posttest survey with 4 categories and missing value. I would like to combine&amp;nbsp;'Definitely yes' and&amp;nbsp;'Probably yes' into "Yes", 'Probably not' and&amp;nbsp;'Definitely not' into "No" so each survey question will have "yes, no and missing", three categories in total. Since I have a list of 14 questions like this, I would like to develop a macro so I don't need to write 14 redundant codes like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Smoke1;&lt;BR /&gt;set Smoke;&lt;/P&gt;&lt;P&gt;/*pretest question 1*/&lt;BR /&gt;if pre_B1_dan_c = 'Definitely yes' then pre_B1_dan_c_D = " Yes";&lt;BR /&gt;if pre_B1_dan_c = 'Probably yes' then pre_B1_dan_c_D = " Yes";&lt;BR /&gt;if pre_B1_dan_c = 'Probably not' then pre_B1_dan_c_D = " No";&lt;BR /&gt;if pre_B1_dan_c = 'Definitely not' then pre_B1_dan_c_D = " No";&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;/*posttest question 1*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;if po_B1_dan_c = 'Definitely yes' then po_B1_dan_c_D = " Yes";&lt;BR /&gt;if po_B1_dan_c = 'Probably yes' then po_B1_dan_c_D = " Yes";&lt;BR /&gt;if po_B1_dan_c = 'Probably not' then po_B1_dan_c_D = " No";&lt;BR /&gt;if po_B1_dan_c = 'Definitely not' then po_B1_dan_c_D = " No";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone please help me with the macro? Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 15:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496258#M131196</guid>
      <dc:creator>Denali</dc:creator>
      <dc:date>2018-09-17T15:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a macro to dichotomize categories in the data step for 14 survey questions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496262#M131198</link>
      <description>You want an array, not a macro here. &lt;BR /&gt;&lt;BR /&gt;See the examples here:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-arrays/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-arrays/&lt;/A&gt;</description>
      <pubDate>Mon, 17 Sep 2018 15:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496262#M131198</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-17T15:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a macro to dichotomize categories in the data step for 14 survey questions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496263#M131199</link>
      <description>&lt;P&gt;Use a format:&lt;/P&gt;
&lt;PRE&gt;proc format;
  value $ynm
    "Definately yes","Probably yes"="Yes"
    other="Yes";
run;
data smoke1;
  set smoke;
  format pre_b1_dan_c po_b1_dan_c $ynm.;
run;&lt;/PRE&gt;
&lt;P&gt;Note, not tested as you have not supplied any test data in the form of a datastep which we always ask for and is mentioned under the Post question button.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 15:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496263#M131199</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-17T15:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a macro to dichotomize categories in the data step for 14 survey questions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496264#M131200</link>
      <description>&lt;P&gt;You can use a format :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value $yn
        "Definitely yes", "Probably yes"="Yes"
        "Definitely not", "Probably not"="No"
        other=" ";
run;

data have;
    length pre_B1_dan_c po_B1_dan_c $15.;
    pre_B1_dan_c="Definitely yes"; po_B1_dan_c="Probably not"; output;
    pre_B1_dan_c="Probably yes"; po_B1_dan_c="Definitely not"; output;
    pre_B1_dan_c=" "; po_B1_dan_c="Probably not"; output;
run;

data want;
    set have;
    pre_B1_dan_c=put(pre_B1_dan_c,$yn.);
	po_B1_dan_c=put(po_B1_dan_c,$yn.);
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Sep 2018 15:17:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496264#M131200</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-09-17T15:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a macro to dichotomize categories in the data step for 14 survey questions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496295#M131207</link>
      <description>&lt;P&gt;Thanks for your suggestions. I am attaching my dataset here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the list of variables to be dichotimized:&lt;/P&gt;&lt;P&gt;pre_B1_dan_c po_B1_dan_c pre_B2_dan_ec po_B2_dan_ec pre_B3_harm_c po_B3_harm_c&lt;BR /&gt;pre_B4_harm_ec po_B4_harm_ec pre_B5_quit_ec po_B5_quit_ec pre_B6_addict_c po_B6_addict_c pre_B7_addict_ec po_B7_addict_ec pre_B8_media po_B8_media&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was testing the proc format code that you&lt;SPAN class="login-bold"&gt;&amp;nbsp;&lt;/SPAN&gt;suggested, but I would like to keep the original variable "pre_B1_dan_c" and create a new variable&amp;nbsp; "pre_B1_dan_c_D" with dichotimize categories. This way I will have both raw information and combined categories in the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 3 pairs of questions (&lt;SPAN&gt;&amp;nbsp;pre_B6_addict_c, po_B6_addict_c, pre_B7_addict_ec, po_B7_addict_ec, pre_B8_media and po_B8_media&lt;/SPAN&gt;) have different categories to dichotomize,&amp;nbsp;please see format $ynB.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;value $ynA&lt;BR /&gt;"Definitely yes", "Probably yes"="Yes"&lt;BR /&gt;"Definitely not", "Probably not"="No"&lt;BR /&gt;other=" ";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;value $ynB&lt;BR /&gt;"Very likely", "Somewhat likely" = "Yes"&lt;BR /&gt;"Neither likely or unlikely", 'Somewhat unlikely', 'Very unlikely' = "No";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help me with refining my code? Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 16:15:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496295#M131207</guid>
      <dc:creator>Denali</dc:creator>
      <dc:date>2018-09-17T16:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a macro to dichotomize categories in the data step for 14 survey questions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496299#M131211</link>
      <description>&lt;P&gt;Right now my code is as below, but it is very long if I include the all the variables.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Smoke1;&lt;BR /&gt;set Smoke;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if pre_B1_dan_c = 'Definitely yes' then pre_B1_dan_c_D = " Yes";&lt;BR /&gt;if pre_B1_dan_c = 'Probably yes' then pre_B1_dan_c_D = " Yes";&lt;BR /&gt;if pre_B1_dan_c = 'Probably not' then pre_B1_dan_c_D = " No";&lt;BR /&gt;if pre_B1_dan_c = 'Definitely not' then pre_B1_dan_c_D = " No";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if po_B1_dan_c = 'Definitely yes' then po_B1_dan_c_D = " Yes";&lt;BR /&gt;if po_B1_dan_c = 'Probably yes' then po_B1_dan_c_D = " Yes";&lt;BR /&gt;if po_B1_dan_c = 'Probably not' then po_B1_dan_c_D = " No";&lt;BR /&gt;if po_B1_dan_c = 'Definitely not' then po_B1_dan_c_D = " No";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if pre_B2_dan_ec = 'Definitely yes' then pre_B2_dan_ec_D = " Yes";&lt;BR /&gt;if pre_B2_dan_ec = 'Probably yes' then pre_B2_dan_ec_D = " Yes";&lt;BR /&gt;if pre_B2_dan_ec = 'Probably not' then pre_B2_dan_ec_D = " No";&lt;BR /&gt;if pre_B2_dan_ec = 'Definitely not' then pre_B2_dan_ec_D = " No";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if po_B2_dan_ec = 'Definitely yes' then po_B2_dan_ec_D = " Yes";&lt;BR /&gt;if po_B2_dan_ec = 'Probably yes' then po_B2_dan_ec_D = " Yes";&lt;BR /&gt;if po_B2_dan_ec = 'Probably not' then po_B2_dan_ec_D = " No";&lt;BR /&gt;if po_B2_dan_ec = 'Definitely not' then po_B2_dan_ec_D = " No";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if pre_B3_harm_c = 'Definitely yes' then pre_B3_harm_c_D = " Yes";&lt;BR /&gt;if pre_B3_harm_c = 'Probably yes' then pre_B3_harm_c_D = " Yes";&lt;BR /&gt;if pre_B3_harm_c = 'Probably not' then pre_B3_harm_c_D = " No";&lt;BR /&gt;if pre_B3_harm_c = 'Definitely not' then pre_B3_harm_c_D = " No";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if po_B3_harm_c = 'Definitely yes' then po_B3_harm_c_D = " Yes";&lt;BR /&gt;if po_B3_harm_c = 'Probably yes' then po_B3_harm_c_D = " Yes";&lt;BR /&gt;if po_B3_harm_c = 'Probably not' then po_B3_harm_c_D = " No";&lt;BR /&gt;if po_B3_harm_c = 'Definitely not' then po_B3_harm_c_D = " No";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 16:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496299#M131211</guid>
      <dc:creator>Denali</dc:creator>
      <dc:date>2018-09-17T16:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a macro to dichotomize categories in the data step for 14 survey questions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496300#M131212</link>
      <description>Did you look at using arrays as mentioned? The tutorial is pretty straightforward.</description>
      <pubDate>Mon, 17 Sep 2018 16:37:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496300#M131212</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-17T16:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a macro to dichotomize categories in the data step for 14 survey questions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496303#M131213</link>
      <description>The use of a format allows to avoid all those ifs. By using an array as suggested by@Reeza, you can perform the same treatments for all your variables.</description>
      <pubDate>Mon, 17 Sep 2018 16:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496303#M131213</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-09-17T16:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a macro to dichotomize categories in the data step for 14 survey questions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496310#M131219</link>
      <description>&lt;P&gt;I am not familiar with the array code...... right now I am still using less simplified code below and got what I want. But I was hoping to refine it using an easier way........&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Smoke1;&lt;BR /&gt;set Smoke;&lt;/P&gt;&lt;P&gt;if pre_B1_dan_c = 'Definitely yes' then pre_B1_dan_c_D = " Yes";&lt;BR /&gt;if pre_B1_dan_c = 'Probably yes' then pre_B1_dan_c_D = " Yes";&lt;BR /&gt;if pre_B1_dan_c = 'Probably not' then pre_B1_dan_c_D = "No";&lt;BR /&gt;if pre_B1_dan_c = 'Definitely not' then pre_B1_dan_c_D = "No";&lt;/P&gt;&lt;P&gt;if po_B1_dan_c = 'Definitely yes' then po_B1_dan_c_D = " Yes";&lt;BR /&gt;if po_B1_dan_c = 'Probably yes' then po_B1_dan_c_D = " Yes";&lt;BR /&gt;if po_B1_dan_c = 'Probably not' then po_B1_dan_c_D = "No";&lt;BR /&gt;if po_B1_dan_c = 'Definitely not' then po_B1_dan_c_D = "No";&lt;/P&gt;&lt;P&gt;if pre_B2_dan_ec = 'Definitely yes' then pre_B2_dan_ec_D = " Yes";&lt;BR /&gt;if pre_B2_dan_ec = 'Probably yes' then pre_B2_dan_ec_D = " Yes";&lt;BR /&gt;if pre_B2_dan_ec = 'Probably not' then pre_B2_dan_ec_D = "No";&lt;BR /&gt;if pre_B2_dan_ec = 'Definitely not' then pre_B2_dan_ec_D = "No";&lt;/P&gt;&lt;P&gt;if po_B2_dan_ec = 'Definitely yes' then po_B2_dan_ec_D = " Yes";&lt;BR /&gt;if po_B2_dan_ec = 'Probably yes' then po_B2_dan_ec_D = " Yes";&lt;BR /&gt;if po_B2_dan_ec = 'Probably not' then po_B2_dan_ec_D = "No";&lt;BR /&gt;if po_B2_dan_ec = 'Definitely not' then po_B2_dan_ec_D = "No";&lt;/P&gt;&lt;P&gt;if pre_B3_harm_c = 'Definitely yes' then pre_B3_harm_c_D = " Yes";&lt;BR /&gt;if pre_B3_harm_c = 'Probably yes' then pre_B3_harm_c_D = " Yes";&lt;BR /&gt;if pre_B3_harm_c = 'Probably not' then pre_B3_harm_c_D = "No";&lt;BR /&gt;if pre_B3_harm_c = 'Definitely not' then pre_B3_harm_c_D = "No";&lt;/P&gt;&lt;P&gt;if po_B3_harm_c = 'Definitely yes' then po_B3_harm_c_D = " Yes";&lt;BR /&gt;if po_B3_harm_c = 'Probably yes' then po_B3_harm_c_D = " Yes";&lt;BR /&gt;if po_B3_harm_c = 'Probably not' then po_B3_harm_c_D = "No";&lt;BR /&gt;if po_B3_harm_c = 'Definitely not' then po_B3_harm_c_D = "No";&lt;/P&gt;&lt;P&gt;if pre_B4_harm_ec = 'Definitely yes' then pre_B4_harm_ec_D = " Yes";&lt;BR /&gt;if pre_B4_harm_ec = 'Probably yes' then pre_B4_harm_ec_D = " Yes";&lt;BR /&gt;if pre_B4_harm_ec = 'Probably not' then pre_B4_harm_ec_D = "No";&lt;BR /&gt;if pre_B4_harm_ec = 'Definitely not' then pre_B4_harm_ec_D = "No";&lt;/P&gt;&lt;P&gt;if po_B4_harm_ec = 'Definitely yes' then po_B4_harm_ec_D = " Yes";&lt;BR /&gt;if po_B4_harm_ec = 'Probably yes' then po_B4_harm_ec_D = " Yes";&lt;BR /&gt;if po_B4_harm_ec = 'Probably not' then po_B4_harm_ec_D = "No";&lt;BR /&gt;if po_B4_harm_ec = 'Definitely not' then po_B4_harm_ec_D = "No";&lt;/P&gt;&lt;P&gt;if pre_B5_quit_ec = 'Definitely yes' then pre_B5_quit_ec_D = " Yes";&lt;BR /&gt;if pre_B5_quit_ec = 'Probably yes' then pre_B5_quit_ec_D = " Yes";&lt;BR /&gt;if pre_B5_quit_ec = 'Probably not' then pre_B5_quit_ec_D = "No";&lt;BR /&gt;if pre_B5_quit_ec = 'Definitely not' then pre_B5_quit_ec_D = "No";&lt;/P&gt;&lt;P&gt;if po_B5_quit_ec = 'Definitely yes' then po_B5_quit_ec_D = " Yes";&lt;BR /&gt;if po_B5_quit_ec = 'Probably yes' then po_B5_quit_ec_D = " Yes";&lt;BR /&gt;if po_B5_quit_ec = 'Probably not' then po_B5_quit_ec_D = "No";&lt;BR /&gt;if po_B5_quit_ec = 'Definitely not' then po_B5_quit_ec_D = "No";&lt;/P&gt;&lt;P&gt;if pre_B6_addict_c = 'Very likely' then pre_B6_addict_c_D = " Yes";&lt;BR /&gt;if pre_B6_addict_c = 'Somewhat likely' then pre_B6_addict_c_D = " Yes";&lt;BR /&gt;if pre_B6_addict_c = 'Neither likely or unlikely' then pre_B6_addict_c_D = "No";&lt;BR /&gt;if pre_B6_addict_c = 'Somewhat unlikely' then pre_B6_addict_c_D = "No";&lt;BR /&gt;if pre_B6_addict_c = 'Very unlikely' then pre_B6_addict_c_D = "No";&lt;/P&gt;&lt;P&gt;if po_B6_addict_c = 'Very likely' then po_B6_addict_c_D = " Yes";&lt;BR /&gt;if po_B6_addict_c = 'Somewhat likely' then po_B6_addict_c_D = " Yes";&lt;BR /&gt;if po_B6_addict_c = 'Neither likely or unlikely' then po_B6_addict_c_D = "No";&lt;BR /&gt;if po_B6_addict_c = 'Somewhat unlikely' then po_B6_addict_c_D = "No";&lt;BR /&gt;if po_B6_addict_c = 'Very unlikely' then po_B6_addict_c_D = "No";&lt;/P&gt;&lt;P&gt;if pre_B7_addict_ec = 'Very likely' then pre_B7_addict_ec_D = " Yes";&lt;BR /&gt;if pre_B7_addict_ec = 'Somewhat likely' then pre_B7_addict_ec_D = " Yes";&lt;BR /&gt;if pre_B7_addict_ec = 'Neither likely or unlikely' then pre_B7_addict_ec_D = "No";&lt;BR /&gt;if pre_B7_addict_ec = 'Somewhat unlikely' then pre_B7_addict_ec_D = "No";&lt;BR /&gt;if pre_B7_addict_ec = 'Very unlikely' then pre_B7_addict_ec_D = "No";&lt;/P&gt;&lt;P&gt;if po_B7_addict_ec = 'Very likely' then po_B7_addict_ec_D = " Yes";&lt;BR /&gt;if po_B7_addict_ec = 'Somewhat likely' then po_B7_addict_ec_D = " Yes";&lt;BR /&gt;if po_B7_addict_ec = 'Neither likely or unlikely' then po_B7_addict_ec_D = "No";&lt;BR /&gt;if po_B7_addict_ec = 'Somewhat unlikely' then po_B7_addict_ec_D = "No";&lt;BR /&gt;if po_B7_addict_ec = 'Very unlikely' then po_B7_addict_ec_D = "No";&lt;/P&gt;&lt;P&gt;if pre_B8_media = 'Very likely' then pre_B8_media_D = " Yes";&lt;BR /&gt;if pre_B8_media = 'Somewhat likely' then pre_B8_media_D = " Yes";&lt;BR /&gt;if pre_B8_media = 'Neither likely or unlikely' then pre_B8_media_D = "No";&lt;BR /&gt;if pre_B8_media = 'Somewhat unlikely' then pre_B8_media_D = "No";&lt;BR /&gt;if pre_B8_media = 'Very unlikely' then pre_B8_media_D = "No";&lt;/P&gt;&lt;P&gt;if po_B8_media = 'Very likely' then po_B8_media_D = " Yes";&lt;BR /&gt;if po_B8_media = 'Somewhat likely' then po_B8_media_D = " Yes";&lt;BR /&gt;if po_B8_media = 'Neither likely or unlikely' then po_B8_media_D = "No";&lt;BR /&gt;if po_B8_media = 'Somewhat unlikely' then po_B8_media_D = "No";&lt;BR /&gt;if po_B8_media = 'Very unlikely' then po_B8_media_D = "No";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 17:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496310#M131219</guid>
      <dc:creator>Denali</dc:creator>
      <dc:date>2018-09-17T17:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a macro to dichotomize categories in the data step for 14 survey questions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496315#M131224</link>
      <description>&lt;P&gt;The first &amp;amp; third examples in the link exactly your situation, recoding variables. Is there something there that's not making sense? Did you have any issues running the example code?&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/140136"&gt;@Denali&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am not familiar with the array code...... right now I am still using less simplified code below and got what I want. But I was hoping to refine it using an easier way........&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 17 Sep 2018 17:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496315#M131224</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-17T17:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a macro to dichotomize categories in the data step for 14 survey questions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496486#M131326</link>
      <description>&lt;P&gt;Here is a solution using sashelp.vcolumn to determine the columns to transform&amp;nbsp; :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value $yn
        "Definitely yes", "Probably yes"="Yes"
        "Definitely not", "Probably not"="No"
        other=" ";
run;

data have;
    length pre_B1_dan_c po_B1_dan_c $15.;
    pre_B1_dan_c="Definitely yes"; po_B1_dan_c="Probably not"; output;
    pre_B1_dan_c="Probably yes"; po_B1_dan_c="Definitely not"; output;
    pre_B1_dan_c=" "; po_B1_dan_c="Probably not"; output;
run;

data _NULL_;
    call execute("data want; set have;");
    
    do until(eof);
        set sashelp.vcolumn end=eof;
        where LIBNAME="WORK" and MEMNAME="HAVE" 
          and (upcase(NAME)=:"PRE_B" or upcase(NAME)=:"PO_B");

        call execute('length '||cats(NAME,'_D')||' $3;');
        call execute(cats(NAME, '_D=put(',NAME,',$yn.);'));
    end;
    call execute('run;');

    stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Sep 2018 07:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-a-macro-to-dichotomize-categories-in-the-data-step/m-p/496486#M131326</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-09-18T07:37:59Z</dc:date>
    </item>
  </channel>
</rss>

