<?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 sas not recognizing formatted values when creating new variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407939#M99458</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one formatted variable (interaction_type2) and I can't figure out how to get SAS to recognize the formatted terms to create new variables or to subset? This code returns missing values for both new variables, because SAS is looking for the unformatted value. Can someone explain this to me? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc format;&lt;/P&gt;&lt;P&gt;Value $interaction&lt;BR /&gt;'01'='Ambulatory patient services'&lt;BR /&gt;'02'='Day surgery patient'&lt;BR /&gt;'03'='Emergency patient'&lt;BR /&gt;'04'='Home visits'&lt;BR /&gt;'05'='Hospice'&lt;BR /&gt;'06'='Imaging'&lt;BR /&gt;'07'='Inpatient'&lt;BR /&gt;'08'='Inpatient psych'&lt;BR /&gt;'09'='Inpatient rehab'&lt;BR /&gt;'10'='Labs and diagnostics.nonimaging'&lt;BR /&gt;'11'='Letter / Email'&lt;BR /&gt;'12'='Not recorded'&lt;BR /&gt;'13'='Nursing home / Assisted living'&lt;BR /&gt;'14'='Observation patient'&lt;BR /&gt;'15'='Office or clinic patient'&lt;BR /&gt;'16'='Other orders'&lt;BR /&gt;'17'='Other patient type'&lt;BR /&gt;'18'='Other physician advice'&lt;BR /&gt;'19'='Palliative care'&lt;BR /&gt;'20'='Prescriptions and refills'&lt;BR /&gt;'21'='Skilled nursing facility inpatient'&lt;BR /&gt;'22'='Swing bed'&lt;BR /&gt;'23'='Unknown patient type'&lt;BR /&gt;'24'='Urgent care'&lt;BR /&gt;'25'='Long term acute care'&lt;BR /&gt;'26'='Other Reports / Results'&lt;BR /&gt;'27'='Telephone / Online';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Value $providerrole&lt;BR /&gt;'01'='ADMITTING'&lt;BR /&gt;'02'='ATTENDING'&lt;BR /&gt;'03'='BILLING'&lt;BR /&gt;'04'='CONSULTING'&lt;BR /&gt;'05'='DISCHARGING'&lt;BR /&gt;'06'='ORDERING'&lt;BR /&gt;'07'='OTHER'&lt;BR /&gt;'08'='PERFORMING'&lt;BR /&gt;'09'='REFERRING'&lt;BR /&gt;'10'='SCHEDULING';&lt;/P&gt;&lt;P&gt;format interaction_type2 $interaction. provider_role2 $providerrole.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data encounter; set m.provider_2007_to_2017_tr;&lt;BR /&gt;if specialty in ("Family Medicine" "Internal Medicine" "Primary Care" "Cardiology" "Emergency Medicine") ;&lt;BR /&gt;if interaction_type2 in (&lt;BR /&gt;'Office or clinic patient'&lt;BR /&gt;) then outpt = 1;&lt;BR /&gt;else if interaction_type2 in (&lt;BR /&gt;'Ambulatory patient services'&lt;BR /&gt;'Day surgery patient'&lt;BR /&gt;'Emergency patient'&lt;BR /&gt;'Inpatient'&lt;BR /&gt;'Inpatient psych'&lt;BR /&gt;'Inpatient rehab'&lt;BR /&gt;'Observation patient'&lt;BR /&gt;'Skilled nursing facility inpatient'&lt;BR /&gt;'Swing bed'&lt;BR /&gt;) then inpt = 1;&lt;BR /&gt;/*format interaction_type2 $interaction. provider_role2 $providerrole.; */&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Oct 2017 08:01:31 GMT</pubDate>
    <dc:creator>psh23</dc:creator>
    <dc:date>2017-10-27T08:01:31Z</dc:date>
    <item>
      <title>sas not recognizing formatted values when creating new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407939#M99458</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one formatted variable (interaction_type2) and I can't figure out how to get SAS to recognize the formatted terms to create new variables or to subset? This code returns missing values for both new variables, because SAS is looking for the unformatted value. Can someone explain this to me? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc format;&lt;/P&gt;&lt;P&gt;Value $interaction&lt;BR /&gt;'01'='Ambulatory patient services'&lt;BR /&gt;'02'='Day surgery patient'&lt;BR /&gt;'03'='Emergency patient'&lt;BR /&gt;'04'='Home visits'&lt;BR /&gt;'05'='Hospice'&lt;BR /&gt;'06'='Imaging'&lt;BR /&gt;'07'='Inpatient'&lt;BR /&gt;'08'='Inpatient psych'&lt;BR /&gt;'09'='Inpatient rehab'&lt;BR /&gt;'10'='Labs and diagnostics.nonimaging'&lt;BR /&gt;'11'='Letter / Email'&lt;BR /&gt;'12'='Not recorded'&lt;BR /&gt;'13'='Nursing home / Assisted living'&lt;BR /&gt;'14'='Observation patient'&lt;BR /&gt;'15'='Office or clinic patient'&lt;BR /&gt;'16'='Other orders'&lt;BR /&gt;'17'='Other patient type'&lt;BR /&gt;'18'='Other physician advice'&lt;BR /&gt;'19'='Palliative care'&lt;BR /&gt;'20'='Prescriptions and refills'&lt;BR /&gt;'21'='Skilled nursing facility inpatient'&lt;BR /&gt;'22'='Swing bed'&lt;BR /&gt;'23'='Unknown patient type'&lt;BR /&gt;'24'='Urgent care'&lt;BR /&gt;'25'='Long term acute care'&lt;BR /&gt;'26'='Other Reports / Results'&lt;BR /&gt;'27'='Telephone / Online';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Value $providerrole&lt;BR /&gt;'01'='ADMITTING'&lt;BR /&gt;'02'='ATTENDING'&lt;BR /&gt;'03'='BILLING'&lt;BR /&gt;'04'='CONSULTING'&lt;BR /&gt;'05'='DISCHARGING'&lt;BR /&gt;'06'='ORDERING'&lt;BR /&gt;'07'='OTHER'&lt;BR /&gt;'08'='PERFORMING'&lt;BR /&gt;'09'='REFERRING'&lt;BR /&gt;'10'='SCHEDULING';&lt;/P&gt;&lt;P&gt;format interaction_type2 $interaction. provider_role2 $providerrole.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data encounter; set m.provider_2007_to_2017_tr;&lt;BR /&gt;if specialty in ("Family Medicine" "Internal Medicine" "Primary Care" "Cardiology" "Emergency Medicine") ;&lt;BR /&gt;if interaction_type2 in (&lt;BR /&gt;'Office or clinic patient'&lt;BR /&gt;) then outpt = 1;&lt;BR /&gt;else if interaction_type2 in (&lt;BR /&gt;'Ambulatory patient services'&lt;BR /&gt;'Day surgery patient'&lt;BR /&gt;'Emergency patient'&lt;BR /&gt;'Inpatient'&lt;BR /&gt;'Inpatient psych'&lt;BR /&gt;'Inpatient rehab'&lt;BR /&gt;'Observation patient'&lt;BR /&gt;'Skilled nursing facility inpatient'&lt;BR /&gt;'Swing bed'&lt;BR /&gt;) then inpt = 1;&lt;BR /&gt;/*format interaction_type2 $interaction. provider_role2 $providerrole.; */&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 08:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407939#M99458</guid>
      <dc:creator>psh23</dc:creator>
      <dc:date>2017-10-27T08:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: sas not recognizing formatted values when creating new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407944#M99461</link>
      <description>&lt;P&gt;You need to have the FORMAT statement actually in the data step - I'm a little surprised your Proc Format doesn't error to be honest - here's a simple example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	format interaction_type2 $interaction. provider_role2 $providerrole.;
	interaction_type2='01';
	provider_role2='02';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Oct 2017 08:20:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407944#M99461</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-10-27T08:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: sas not recognizing formatted values when creating new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407946#M99462</link>
      <description>&lt;P&gt;I do have a format in the data step, it is commented out at the end of the code&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 08:24:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407946#M99462</guid>
      <dc:creator>psh23</dc:creator>
      <dc:date>2017-10-27T08:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: sas not recognizing formatted values when creating new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407953#M99465</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/116280"&gt;@psh23&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;You would normally use the codes and not the labels in selections and then just have an inline comment what you're selecting.&lt;/P&gt;
&lt;P&gt;If you want to use the&amp;nbsp;labels then you need to write these&amp;nbsp;labels first as done below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  if put(interaction_type2,$interaction.) in ( 'Office or clinic patient' ) then
    outpt = 1;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Oct 2017 08:44:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407953#M99465</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-27T08:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: sas not recognizing formatted values when creating new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407954#M99466</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 08:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407954#M99466</guid>
      <dc:creator>psh23</dc:creator>
      <dc:date>2017-10-27T08:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: sas not recognizing formatted values when creating new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407955#M99467</link>
      <description>&lt;P&gt;My point exactly - SAS isn't going to use it if it's commented out......&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 08:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-not-recognizing-formatted-values-when-creating-new-variable/m-p/407955#M99467</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-10-27T08:48:57Z</dc:date>
    </item>
  </channel>
</rss>

