<?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: Numeric column with character data. PUT/Input not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Numeric-column-with-character-data-PUT-Input-not-working/m-p/871855#M344457</link>
    <description>&lt;P&gt;A numeric variable cannot contain strings like A00.&amp;nbsp; So if the variable is numeric and when you print the values you see strings like A00 then that is the result of applying the format to the numeric values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you want to see the actual numbers then just display the variable without the format attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if your existing dataset is named HAVE and existing variable is named CLAIMS try running this code to see what the values actually look like.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  new_number=claims;
run;
proc freq data=want;
  tables new_number*claims / list missing;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You should see an output that shows that 1 is mapped to 'No Claims' and 7 is mapped to 'A00' etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you want to recode the numbers you could just write logic to do it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   select (claims);
      when (1) then new_number=0;
      when (7) then new_number=1;
      ...
      other new_number=.;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to use formats or informats to do the re-mapping then you will need to create an INFORMAT that can map the values displayed by your existing FORMAT to the numbers you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue recode 
   'No Claims'=0
   'A00'=1
   ....
  ;
run;
data want;
  set have;
  new_number = input(vvalue(CLAIM),recode.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Apr 2023 13:18:52 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-04-25T13:18:52Z</dc:date>
    <item>
      <title>Numeric column with character data. PUT/Input not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numeric-column-with-character-data-PUT-Input-not-working/m-p/871843#M344452</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to format a column which is defined as numeric but have character data. Details are as below:&lt;/P&gt;&lt;P&gt;Length 3.&lt;/P&gt;&lt;P&gt;Format FCLMS6A9.&lt;/P&gt;&lt;P&gt;Informat 9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Values:&lt;/P&gt;&lt;P&gt;No Claims&lt;/P&gt;&lt;P&gt;A00&lt;/P&gt;&lt;P&gt;0A0&lt;/P&gt;&lt;P&gt;5+&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;00A&lt;/P&gt;&lt;P&gt;200&lt;/P&gt;&lt;P&gt;011&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to format as :&lt;/P&gt;&lt;P&gt;if 'No Claims' then 0;&lt;/P&gt;&lt;P&gt;if '00A' then 1; if '011' then 2 etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried PUT function, user defined format but nothing is working. Every time either SAS returns missing values or by default it converts&lt;/P&gt;&lt;P&gt;'No Claims' to 1,&lt;/P&gt;&lt;P&gt;'A00' to 7,&lt;/P&gt;&lt;P&gt;'00A' to 5, '011' to 8, 200 to 13 etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way out?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 12:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numeric-column-with-character-data-PUT-Input-not-working/m-p/871843#M344452</guid>
      <dc:creator>Shri04</dc:creator>
      <dc:date>2023-04-25T12:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric column with character data. PUT/Input not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numeric-column-with-character-data-PUT-Input-not-working/m-p/871844#M344453</link>
      <description>&lt;P&gt;I recommend you look at the documentation for&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p1xidhqypi0fnwn1if8opjpqpbmn.htm" target="_self"&gt;PROC FORMAT&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here's a simple example using the PROC FORMAT CNTLIN data to create a custom format&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/* Create a PROC FORMAT cntlin dataset and a sample "have" dataset */
data 
	work.cntlin 
	work.have (keep=start) 
	;
	retain
		fmtName "$myCustomFormat" 
		label   0 
		;
	infile cards ;
	input 
		start $10. ;
	output work.cntlin ;
	label+1 ;
	output 
		work.cntlin 
		work.have ;
cards ;
No Claims
A00
0A0
5+
3
4
00A
200
011
;
run ;

/* Create character myCustomFormat using cntlin data */
proc format cntlin=work.cntlin ;
run ;

/* test myCustomFormat against sample "have" data */
data want ;
	set work.have ;
	want=putc(start,"$myCustomFormat.") ;
	put start= want= ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Apr 2023 12:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numeric-column-with-character-data-PUT-Input-not-working/m-p/871844#M344453</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2023-04-25T12:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric column with character data. PUT/Input not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numeric-column-with-character-data-PUT-Input-not-working/m-p/871846#M344454</link>
      <description>&lt;P&gt;Essentially, the format&amp;nbsp;&lt;SPAN&gt;FCLMS6A9. makes the numeric value appear as character. But the values are still numeric. That's what formats do, they change the appearance of data, without changing the value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I think to provide further help, we would need to see the PROC FORMAT code that creates format&amp;nbsp;FCLMS6A.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 13:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numeric-column-with-character-data-PUT-Input-not-working/m-p/871846#M344454</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-25T13:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric column with character data. PUT/Input not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numeric-column-with-character-data-PUT-Input-not-working/m-p/871848#M344455</link>
      <description>&lt;P&gt;hello please send completed code you have to help you&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 12:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numeric-column-with-character-data-PUT-Input-not-working/m-p/871848#M344455</guid>
      <dc:creator>juansalasa</dc:creator>
      <dc:date>2023-04-25T12:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric column with character data. PUT/Input not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numeric-column-with-character-data-PUT-Input-not-working/m-p/871855#M344457</link>
      <description>&lt;P&gt;A numeric variable cannot contain strings like A00.&amp;nbsp; So if the variable is numeric and when you print the values you see strings like A00 then that is the result of applying the format to the numeric values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you want to see the actual numbers then just display the variable without the format attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if your existing dataset is named HAVE and existing variable is named CLAIMS try running this code to see what the values actually look like.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  new_number=claims;
run;
proc freq data=want;
  tables new_number*claims / list missing;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You should see an output that shows that 1 is mapped to 'No Claims' and 7 is mapped to 'A00' etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you want to recode the numbers you could just write logic to do it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   select (claims);
      when (1) then new_number=0;
      when (7) then new_number=1;
      ...
      other new_number=.;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to use formats or informats to do the re-mapping then you will need to create an INFORMAT that can map the values displayed by your existing FORMAT to the numbers you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue recode 
   'No Claims'=0
   'A00'=1
   ....
  ;
run;
data want;
  set have;
  new_number = input(vvalue(CLAIM),recode.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 13:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numeric-column-with-character-data-PUT-Input-not-working/m-p/871855#M344457</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-25T13:18:52Z</dc:date>
    </item>
  </channel>
</rss>

