<?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: Transforming 4 pt likert into distinct binary in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Transforming-4-pt-likert-into-distinct-binary/m-p/131283#M1792</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't have to modify any data for most purposes. A custom format such as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc format library=work;&lt;/P&gt;&lt;P&gt;value MyBin&lt;/P&gt;&lt;P&gt;1,2 = '0' /* or you can use False, No or whatever 0 actually means to you in place of 0*/&lt;/P&gt;&lt;P&gt;3,4 = '1' /* or True, Yes or whatever*/&lt;/P&gt;&lt;P&gt;5= .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in analysis procedures or any display associate the format with the variable.&lt;/P&gt;&lt;P&gt;proc freq data=yourdatasetname;&lt;/P&gt;&lt;P&gt;tables tml021success;&lt;/P&gt;&lt;P&gt;format tml021success MyBin. ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One advantage of this approach is that you can have multiple formats that can be assigned to the same variables for different types of analysis and don't have to create multiple variables such as if you wanted to see how groups based on 1, 2 and 3, 4.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Sep 2013 19:36:10 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2013-09-06T19:36:10Z</dc:date>
    <item>
      <title>Transforming 4 pt likert into distinct binary</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Transforming-4-pt-likert-into-distinct-binary/m-p/131282#M1791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ran a proc contents with an out= to create a dataset that has all of the variables in a single column.&amp;nbsp; From here I want to be able to perform a handful of transformations based on the middle position of said variables, they look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tml021success&lt;/P&gt;&lt;P&gt;tml021datainform&lt;/P&gt;&lt;P&gt;...there are approx 100 of these vars, and I only want to transform into new vars those vars that have an '046' or '021' as their substr(name,4,3)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the transformation is to make tml021success (1 thru 2=0)&amp;nbsp; (3 thru 4 = 1) 5=sysmis into ra_tml021success.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;questions is:&amp;nbsp; What proc do I use (or macro) to make the program loop through and identify those vars with a specific substring and recode them into newly created vars?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help much appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Novice sas user&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 16:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Transforming-4-pt-likert-into-distinct-binary/m-p/131282#M1791</guid>
      <dc:creator>pdougherty</dc:creator>
      <dc:date>2013-09-06T16:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming 4 pt likert into distinct binary</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Transforming-4-pt-likert-into-distinct-binary/m-p/131283#M1792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't have to modify any data for most purposes. A custom format such as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc format library=work;&lt;/P&gt;&lt;P&gt;value MyBin&lt;/P&gt;&lt;P&gt;1,2 = '0' /* or you can use False, No or whatever 0 actually means to you in place of 0*/&lt;/P&gt;&lt;P&gt;3,4 = '1' /* or True, Yes or whatever*/&lt;/P&gt;&lt;P&gt;5= .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in analysis procedures or any display associate the format with the variable.&lt;/P&gt;&lt;P&gt;proc freq data=yourdatasetname;&lt;/P&gt;&lt;P&gt;tables tml021success;&lt;/P&gt;&lt;P&gt;format tml021success MyBin. ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One advantage of this approach is that you can have multiple formats that can be assigned to the same variables for different types of analysis and don't have to create multiple variables such as if you wanted to see how groups based on 1, 2 and 3, 4.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 19:36:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Transforming-4-pt-likert-into-distinct-binary/m-p/131283#M1792</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-09-06T19:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming 4 pt likert into distinct binary</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Transforming-4-pt-likert-into-distinct-binary/m-p/131284#M1793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have two questions here.&lt;/P&gt;&lt;P&gt;1) How to recode one of these variables.&lt;/P&gt;&lt;P&gt;2) How to simplify identifying all of them and generating the code to re code them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One way to generate the list of variable names needed to define an array is to use PROC SQL to make a macro variable with the space delimited list of variable names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql noprint ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; select name , 'ra_'||name&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; line-height: 1.5em;"&gt;into : original separated by ' '&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , : recoded separated by ' '&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from contents&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where substr(name,4,3) in ('021','046')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One simple way to apply the same logic to multiple variables is to use an ARRAY ( or in this case two synchronized arrays).&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set have ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; array _a &amp;amp;original;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; array _b &amp;amp;recoded ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do over _a ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if 1 &amp;lt;= _a &amp;lt;= 2 then _b = 0 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if 3 &amp;lt;= _a &amp;lt;= 4 then _b=1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else _b=.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 19:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Transforming-4-pt-likert-into-distinct-binary/m-p/131284#M1793</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-09-06T19:52:40Z</dc:date>
    </item>
  </channel>
</rss>

