<?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: char or numeric var after apply format in put in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/char-or-numeric-var-after-apply-format-in-put/m-p/941303#M369332</link>
    <description>&lt;P&gt;It's not numeric!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
x_char='High_50-100%-Med_0-50%-Low_0-50%';
W=put(compress(X_CHAR),$F1_High_Risk_ithalv.);
run;
proc contents;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1724833108861.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99684iBF7B1E8802E2D1DE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1724833108861.png" alt="yabwon_0-1724833108861.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;SAS just let's you to be a "lazy typer".&lt;/P&gt;
&lt;P&gt;Even though you provide values 1,2,3 without quotes, since you are defining character format, the values 1,2,3, are interpreted as they were "1", "2", "3".&lt;/P&gt;
&lt;P&gt;Of course for better readability adding "" would be good idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Wed, 28 Aug 2024 08:29:31 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2024-08-28T08:29:31Z</dc:date>
    <item>
      <title>char or numeric var after apply format in put</title>
      <link>https://communities.sas.com/t5/SAS-Programming/char-or-numeric-var-after-apply-format-in-put/m-p/941290#M369329</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;X_char is a char var.&lt;/P&gt;
&lt;P&gt;I run following code and expext that resulted VAR (W) be char with values-1,2,3,4&lt;/P&gt;
&lt;P&gt;My question- Why VAR W is numeric???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
value $F1_High_Risk_ithalv
'High_50-100%-Med_0-50%-Low_0-50%',
'High_50-100%-Low_0-50%',
'High_100%',
'High_50-100%-Med_0-50%',
'High_0-50%-Med_50-100%-Low_0-50%',
'High_0-50%-Med_50-100%',
'Med_50-100%-Low_0-50%',
'Med_100%'
=1

'High_0-50%-Med_0-50%-Low_50-100%',
'Med_0-50%-Low_50-100%',
'High_0-50%-Low_50-100%'
=2

'High_0-50%-Med_0-50%-Low_0-50%',
'ithalv=0'
=3

'Low_100%'
=4
;
Run;

W=put(compress(X_CHAR),$F1_High_Risk_ithalv.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Aug 2024 07:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/char-or-numeric-var-after-apply-format-in-put/m-p/941290#M369329</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-08-28T07:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: char or numeric var after apply format in put</title>
      <link>https://communities.sas.com/t5/SAS-Programming/char-or-numeric-var-after-apply-format-in-put/m-p/941292#M369330</link>
      <description>You need put QUOTE around 1,2,3 . Like:&lt;BR /&gt;= '1'&lt;BR /&gt;....&lt;BR /&gt;='2'</description>
      <pubDate>Wed, 28 Aug 2024 07:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/char-or-numeric-var-after-apply-format-in-put/m-p/941292#M369330</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-08-28T07:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: char or numeric var after apply format in put</title>
      <link>https://communities.sas.com/t5/SAS-Programming/char-or-numeric-var-after-apply-format-in-put/m-p/941303#M369332</link>
      <description>&lt;P&gt;It's not numeric!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
x_char='High_50-100%-Med_0-50%-Low_0-50%';
W=put(compress(X_CHAR),$F1_High_Risk_ithalv.);
run;
proc contents;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1724833108861.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99684iBF7B1E8802E2D1DE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1724833108861.png" alt="yabwon_0-1724833108861.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;SAS just let's you to be a "lazy typer".&lt;/P&gt;
&lt;P&gt;Even though you provide values 1,2,3 without quotes, since you are defining character format, the values 1,2,3, are interpreted as they were "1", "2", "3".&lt;/P&gt;
&lt;P&gt;Of course for better readability adding "" would be good idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 08:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/char-or-numeric-var-after-apply-format-in-put/m-p/941303#M369332</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-08-28T08:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: char or numeric var after apply format in put</title>
      <link>https://communities.sas.com/t5/SAS-Programming/char-or-numeric-var-after-apply-format-in-put/m-p/941411#M369337</link>
      <description>&lt;P&gt;Because &lt;STRONG&gt;FORMATs convert VALUES into TEXT&lt;/STRONG&gt;.&amp;nbsp; The result of using PUT() is ALWAYS going to be character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to create a numeric value you need to use an INFORMAT with the INPUT() function.&amp;nbsp; &lt;STRONG&gt;INFORMATs convert TEXT into VALUES&lt;/STRONG&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
invalue F1_High_Risk_ithalv 
 'High_50-100%-Med_0-50%-Low_0-50%'
,'High_50-100%-Low_0-50%'
,'High_100%'
,'High_50-100%-Med_0-50%'
,'High_0-50%-Med_50-100%-Low_0-50%'
,'High_0-50%-Med_50-100%'
,'Med_50-100%-Low_0-50%'
,'Med_100%'
=1

 'High_0-50%-Med_0-50%-Low_50-100%'
,'Med_0-50%-Low_50-100%'
,'High_0-50%-Low_50-100%'
=2

 'High_0-50%-Med_0-50%-Low_0-50%'
,'ithalv=0'
=3

'Low_100%'
=4
;
run;

data test ;
  input x_char $80.;
  W=input(compress(X_CHAR),F1_High_Risk_ithalv.);
cards;
Low_100%
Med_100%
High_0-50%-Low_50-100%
ithalv=0
;;;;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Aug 2024 12:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/char-or-numeric-var-after-apply-format-in-put/m-p/941411#M369337</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-28T12:55:42Z</dc:date>
    </item>
  </channel>
</rss>

