<?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 Issues with variable categorization while subsetting a dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Issues-with-variable-categorization-while-subsetting-a-dataset/m-p/558477#M10104</link>
    <description>&lt;P&gt;I am currently trying to run a macro called PROCESS by Hayes which is used to test moderation and mediation models. However I keep running into the following errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29500i992FAB375CA6D223/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It appears that the error might be due to the fact that my categorical variables are currently string values (words such as "yes" or "no"). When I change the values of these variables to numbers (0 and 1) manually in excel the macro works fine. However, I get the same error when I try to recode the values of the variables in SAS using the subset command. My subsetting code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29501i05E1E0DF0711F964/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would expect that my subsetting code should have the same effect as manually changing the values in excel before importing the data into SAS; however, it appears that SAS is treating them differently. If you have any advice on how I can recode my variables in SAS and have them work the macro I am using I would appreciate the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;</description>
    <pubDate>Mon, 13 May 2019 21:33:42 GMT</pubDate>
    <dc:creator>nballred1</dc:creator>
    <dc:date>2019-05-13T21:33:42Z</dc:date>
    <item>
      <title>Issues with variable categorization while subsetting a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Issues-with-variable-categorization-while-subsetting-a-dataset/m-p/558477#M10104</link>
      <description>&lt;P&gt;I am currently trying to run a macro called PROCESS by Hayes which is used to test moderation and mediation models. However I keep running into the following errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29500i992FAB375CA6D223/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It appears that the error might be due to the fact that my categorical variables are currently string values (words such as "yes" or "no"). When I change the values of these variables to numbers (0 and 1) manually in excel the macro works fine. However, I get the same error when I try to recode the values of the variables in SAS using the subset command. My subsetting code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29501i05E1E0DF0711F964/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would expect that my subsetting code should have the same effect as manually changing the values in excel before importing the data into SAS; however, it appears that SAS is treating them differently. If you have any advice on how I can recode my variables in SAS and have them work the macro I am using I would appreciate the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 21:33:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Issues-with-variable-categorization-while-subsetting-a-dataset/m-p/558477#M10104</guid>
      <dc:creator>nballred1</dc:creator>
      <dc:date>2019-05-13T21:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with variable categorization while subsetting a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Issues-with-variable-categorization-while-subsetting-a-dataset/m-p/558479#M10105</link>
      <description>&lt;P&gt;When running a SAS program, you have to read the log.&amp;nbsp; There are messages that you ignored about numeric to character conversion.&amp;nbsp; What happens ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can't change a variable from being character to being numeric.&amp;nbsp; Once it's character, it remains character.&amp;nbsp; You can jump through the right hoops to get around that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data subset;
   set study;
   if scarce = 'yes' then sc = 1;
   if scarce = 'no' then sc = 0;
   if purchase = 'yes' then pu = 1;
   if purchase = 'no' then pu = 0;
   drop scarce purchase;
   rename sc = scarce pu = purchase;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This program in effect gives you new numeric variables.&amp;nbsp; You can then use DROP and RENAME to keep them under the original names, as numeric.&amp;nbsp; This version of the data should work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 21:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Issues-with-variable-categorization-while-subsetting-a-dataset/m-p/558479#M10105</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-05-13T21:40:58Z</dc:date>
    </item>
  </channel>
</rss>

