<?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: Converting $1. to best12 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386838#M277264</link>
    <description>&lt;P&gt;If SAS made the variables character when you imported, there is probably a reason for it. &amp;nbsp;If the output doesn't get too long, you can try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=new;&lt;/P&gt;
&lt;P&gt;tables _character_;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will likely see values for these variables that cannot be stored as numeric. &amp;nbsp;You would have to decide what to do about them, before anybody can write a program to fix the situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, if you are trying some of the other suggestions posted here, there is no such thing as a best12. informat. &amp;nbsp;You could simply use the 12. informat&amp;nbsp;instead. &amp;nbsp;Best12. is a format, but not an informat.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Aug 2017 23:01:19 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-08-09T23:01:19Z</dc:date>
    <item>
      <title>Converting $1. to best12</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386817#M277260</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been trying to convert some variables from the informat $1. to BEST12. but it's not working. Help please!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data analysis.myco;&lt;BR /&gt;set work.new;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;informat afb1 afm1 afg1 afg2 ata cit dhcit don donglca zen zenglca&lt;BR /&gt;afb_creat afm_creat afg_creat ota_creat dh_cit_creat don_creat donglca_creat zen_creat zenglca_creat $1.;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;format afb1 afm1 afg1 afg2 ata cit dhcit don donglca zen zenglca&lt;BR /&gt;afb_creat afm_creat afg_creat ota_creat dh_cit_creat don_creat donglca_creat zen_creat zenglca_creat best12.;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;input afb1 afm1 afg1 afg2 ata cit dhcit don donglca zen zenglca&lt;BR /&gt;afb_creat afm_creat afg_creat ota_creat dh_cit_creat don_creat donglca_creat zen_creat zenglca_creat;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 21:35:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386817#M277260</guid>
      <dc:creator>NadiaK</dc:creator>
      <dc:date>2017-08-09T21:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Converting $1. to best12</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386826#M277261</link>
      <description>&lt;P&gt;Once a SAS variable has been created you cannot change it's type. You are attempting to change a character to numeric.&lt;/P&gt;
&lt;P&gt;Are you actually INPUTing data (reading from an external file)? If so then change the informat to best12. to read the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want convert you have to decide if you want to keep the variable names (which will require a bunch of rename code) or are willing to accept new variable names.&lt;/P&gt;
&lt;P&gt;Creating new numeric variables (one way, there are others), using just part of the variables.&lt;/P&gt;
&lt;PRE&gt;data analysis.myco;
   set work.new;
   array h  afb1 afm1 afg1 afg2 ata cit dhcit don donglca zen zenglca ;
   array w  afb1_num afm1_num afg1_num afg2_num ata_num cit_num dhcit_num don_num donglca_num zen_num zenglca_num ;
   do i= 1 to dim(h);
      w[i] = input(h[i],best12.);
   end;
run;&lt;/PRE&gt;
&lt;P&gt;reusing the same variable names&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data analysis.myco;
   set work.new (rename = (afb1=afb1_old afm1=afm1_old afg1=afg1_old afg2=afg2_old 
         ata=ata_old cit=cit_old dhcit=dhcit_old don=don_old donglca=donglca_old zen=zen_old zenglca=zenglca_old ) 
   ;
   array h  afb1_old afm1_old afg1_old afg2_old ata_old cit_old dhcit_old don_old donglca_old zen_old zenglca_old;
   array w  afb1 afm1 afg1 afg2 ata cit dhcit don donglca zen zenglca ;
   do i= 1 to dim(h);
      w[i] = input(h[i],best12.);
   end;   
   drop i afb1_old afm1_old afg1_old afg2_old ata_old cit_old dhcit_old don_old donglca_old zen_old zenglca_old;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Better would be to go back to what ever created work.new and read the data values correctly the first time. That many variables with an existing format of $1. tells me the data likely came from proc import AND that the values may be blank.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 22:09:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386826#M277261</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-09T22:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Converting $1. to best12</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386827#M277262</link>
      <description>&lt;P&gt;Did you try input function ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a = input(&lt;EM&gt;variablename&lt;/EM&gt;, best12.);&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 22:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386827#M277262</guid>
      <dc:creator>OnSAS</dc:creator>
      <dc:date>2017-08-09T22:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Converting $1. to best12</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386831#M277263</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;Thanks for the response.&lt;BR /&gt;&lt;BR /&gt;Yes, I used proc import. The data is from .csv file. I made sure to save&lt;BR /&gt;all the variables in numeric format, but in sas it's not showing as&lt;BR /&gt;numeric. So, even when I do go back to the original .csv file, it does not&lt;BR /&gt;work.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Aug 2017 22:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386831#M277263</guid>
      <dc:creator>NadiaK</dc:creator>
      <dc:date>2017-08-09T22:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Converting $1. to best12</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386838#M277264</link>
      <description>&lt;P&gt;If SAS made the variables character when you imported, there is probably a reason for it. &amp;nbsp;If the output doesn't get too long, you can try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=new;&lt;/P&gt;
&lt;P&gt;tables _character_;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will likely see values for these variables that cannot be stored as numeric. &amp;nbsp;You would have to decide what to do about them, before anybody can write a program to fix the situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, if you are trying some of the other suggestions posted here, there is no such thing as a best12. informat. &amp;nbsp;You could simply use the 12. informat&amp;nbsp;instead. &amp;nbsp;Best12. is a format, but not an informat.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 23:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386838#M277264</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-09T23:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Converting $1. to best12</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386839#M277265</link>
      <description>&lt;P&gt;There is no need to use PROC IMPORT to read a CSV file, especially one that you already know what the variables are.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
   infile 'myfile.csv' dsd truncover firstobs=2;
   input afb1 afm1 afg1 afg2 ata cit dhcit 
        don donglca zen zenglca afb_creat
        afm_creat afg_creat ota_creat dh_cit_creat
        don_creat donglca_creat zen_creat zenglca_creat
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There is no need to attach either informats or formats to most variables.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 23:39:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-1-to-best12/m-p/386839#M277265</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-09T23:39:34Z</dc:date>
    </item>
  </channel>
</rss>

