<?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: change type of variables numeric to character in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/634016#M77938</link>
    <description>&lt;P&gt;"&lt;SPAN&gt;&lt;EM&gt;why you put &amp;lt;&amp;gt;&lt;/EM&gt;&lt;/SPAN&gt;"&amp;nbsp; I guess you're talking about this bit:&amp;nbsp;&lt;SPAN&gt;infile '&lt;STRONG&gt;&amp;lt;path&amp;gt;&lt;/STRONG&gt;/Data_projet_AFRIQUE1.txt'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The bit in the &amp;lt;&amp;gt; is a placeholder and what you need to replace with the actual path in your environment (which the Proc Import generated datastep code in the SAS log will provide).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Writing it this way is inspired by &lt;A href="https://go.documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0h6cun31ihdqtn1io0sv70zh5l8.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;SAS syntax conventions&lt;/A&gt;&amp;nbsp;in the documentation (also there the brackets have a slightly different meaning).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;if _ERROR_ then call symputx('_EFIERR_',1);&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That's what Proc Import generates. As a beginner you haven't got to SAS macro variables yet - so just ignore this bit for now.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This code is normally not something people write for a SAS datastep - but because Proc Import generates such code I didn't want to remove it - but don't hesitate to delete below two lines from your code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;....
%let _EFIERR_ = 0; 
....
if _ERROR_ then call symputx('_EFIERR_',1);  
....&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 22 Mar 2020 23:55:30 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2020-03-22T23:55:30Z</dc:date>
    <item>
      <title>change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633947#M77919</link>
      <description>&lt;P&gt;hello ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please i need your help for a problem. I want to change the type of variables (numeric to character).&lt;/P&gt;&lt;P&gt;I have a numeric variable that I want to change to a character. Thank you for helping me please.&lt;BR /&gt;I'm a beginner in SAS. If you want i can put the type file .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 15:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633947#M77919</guid>
      <dc:creator>ks94</dc:creator>
      <dc:date>2020-03-22T15:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633948#M77920</link>
      <description>&lt;P&gt;You can't change the type of a variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a new variable that is character from a numeric variable. You can use any format that works. Here is an example using the format 8.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;char_var=put(numeric_var,8.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Mar 2020 15:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633948#M77920</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-22T15:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633951#M77921</link>
      <description>&lt;P&gt;In the data step with which you read the file, use a character informat for reading that column.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 15:04:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633951#M77921</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-22T15:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633967#M77924</link>
      <description>&lt;P&gt;How did you create variables?&amp;nbsp; All you showed as a text file.&amp;nbsp; Everything in a text file is character.&amp;nbsp; When you read the values you can decide what type of variable you create.&lt;/P&gt;
&lt;P&gt;If you read it with PROC IMPORT then that proc will have to guess how to define the variable based on the example values it sees in this one data file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you write your own data step to read it you get to define the variables.&amp;nbsp; It you don't make any attempt to define them then they will all be numbers.&amp;nbsp;&amp;nbsp;If you define the type and length with a LENGTH statement first then the INPUT statement can be simpler.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'c:\downloads\Data_projet_AFRIQUE2.txt' dsd dlm=';' firstobs=2 truncover;
  length
    case $10 cc3 $30 country $8
    year systemic_crisis exch_usd 
    domestic_debt_in_default 
    sovereign_external_debt_default
    gdp_weighted_default
    inflation_annual_cpi
    independence
    currency_crises
    inflation_crises 8
    banking_crisis  $20
  ;
  input case --  banking_crisis ;
  informat _numeric_ commax.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 16:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633967#M77924</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-22T16:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633968#M77925</link>
      <description>&lt;P&gt;THANKS YOU BUT can you give me the inverse method ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 16:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633968#M77925</guid>
      <dc:creator>ks94</dc:creator>
      <dc:date>2020-03-22T16:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633969#M77926</link>
      <description>&lt;P&gt;Use the&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p19en16vskd2vhn1vwmxpxnglxxs.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;INPUT()&lt;/A&gt;&amp;nbsp;function and a fitting&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=leforinforref&amp;amp;docsetTarget=p13eggx7qc7l6in1oprinvadzubl.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;informat&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 17:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633969#M77926</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-22T17:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633972#M77927</link>
      <description>&lt;P&gt;the variables were created with proc import.&amp;nbsp;the variables were created with proc import and I want to change the type of the variables .&lt;BR /&gt;e.g.: the variable alphanum , i want to convert to numeric without .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 17:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633972#M77927</guid>
      <dc:creator>ks94</dc:creator>
      <dc:date>2020-03-22T17:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633973#M77928</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/317542"&gt;@ks94&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;THANKS YOU BUT can you give me the inverse method ?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You asked for creating character from numeric. That's what I gave you. Now you say you want the inverse? Please clarify, which is it? &lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 22 Mar 2020 17:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633973#M77928</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-22T17:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633974#M77929</link>
      <description>change type of variable character to numeric&lt;BR /&gt;</description>
      <pubDate>Sun, 22 Mar 2020 18:03:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633974#M77929</guid>
      <dc:creator>ks94</dc:creator>
      <dc:date>2020-03-22T18:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633977#M77930</link>
      <description>&lt;P&gt;The best solution is to NOT create the variables using PROC IMPORT.&amp;nbsp; PROC IMPORT on text files is by definition a guessing process.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is not a variable in that dataset named alphanum, which variable(s) do you want to convert?&lt;/P&gt;
&lt;P&gt;Is your problem with the values with the commas in them?&lt;/P&gt;
&lt;PRE&gt;1;DZA;;;0;0,05168;0;0;0;11,20389701;0;0;0;no_crisis&lt;/PRE&gt;
&lt;P&gt;The way the commas are placed and the fact that semi-colon is used as the delimiter instead of comma makes it looks like the commas should treated as decimal places.&amp;nbsp; So you probably need to use the COMMAX informat to convert the strings to numbers.&amp;nbsp; But your locale setting might impact that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  newvar = input(oldvar,commax32.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want the values to print using comma instead of period to mark the decimal place you might need to attach the COMMAX format to the value.&amp;nbsp; But note that once you have the value as a number the format attached does not change the value stored, just how it is displayed as text.&amp;nbsp; The number one thousand two hundred thirty four and a half is the stored the same whether it is displayed as 1,234.5 or 1.234,5 or 001234.500.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 18:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633977#M77930</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-22T18:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633978#M77931</link>
      <description>&lt;P&gt;Try just changing your LOCALE setting:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p12uk352fte2h1n1efh4r44dmxmp.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p12uk352fte2h1n1efh4r44dmxmp.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P class="xisDoc-paragraph"&gt;Beginning with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xisDoc-codeFocus"&gt;SAS 9.4M3&lt;/SPAN&gt;, PROC IMPORT uses the NLNUM informat instead of the COMMA informat. When you import a file that contains values such as 14,000.01 that have commas, the COMMA informat removes the commas and other&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xisDoc-nobr"&gt;non-numeric&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;characters from the numerical values. Removing these characters can cause interpretation errors in the values. NLNUM prevents these errors by using the specified value of the LOCALE system option to interpret numerical values that have commas.&lt;/P&gt;
&lt;P class="xisDoc-paragraph"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="xisDoc-paragraph"&gt;For example, to enter the numerical equivalent of fourteen thousand and one hundredth, a person specifying LOCALE=English_UnitedStates would enter 14,000.01. A person specifying LOCALE=French_France would enter 14.000,01. NLNUM interprets either input value correctly and writes the correct value based on the specified locale. If you read in 14.000,01 with NLNUM and LOCALE=French_France, store it in a data set, and then write it with NLNUM and LOCALE=English_UnitedStates, it is displayed as 14,000.01.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sun, 22 Mar 2020 18:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633978#M77931</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-22T18:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633979#M77932</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/317542"&gt;@ks94&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;the variables were created with proc import.&amp;nbsp;the variables were created with proc import and I want to change the type of the variables .&lt;BR /&gt;e.g.: the variable alphanum , i want to convert to numeric without .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do NOT (as in NEVER) use proc import if you want control over what happens. Use a data step to read the file.&lt;/P&gt;
&lt;P&gt;You can use proc import&amp;nbsp;&lt;EM&gt;once&lt;/EM&gt; to create the data step which you then adapt to your needs.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 18:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633979#M77932</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-22T18:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633992#M77935</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/317542"&gt;@ks94&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc Import lets you quickly read an external file into a SAS table. Using Proc Import means that you delegate the analysis of the source data to SAS - and this also often works as desired. If it doesn't work then you need to take control back meaning you need to write your own datastep.&lt;/P&gt;
&lt;P&gt;Proc Import also creates a SAS datastep to read a text file. This datastep gets written to the SAS log. So if you use Proc Import as discussed &lt;A href="https://communities.sas.com/t5/SAS-Procedures/data-extraction-from-csv-file-to-sas/m-p/633465#M77885" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;and execute it then you'll see in the SAS log the data step. What you can do now is to copy/paste this part of the SAS log into a programming window. You then can use the ALT key and select all the columns on the left side which are not code but part of the log, and then delete them. Also delete any log page header lines (if any). Now you've got fully valid SAS datastep code reading your external file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at the result of the Proc Import I guess you've got an issue with column&amp;nbsp;&lt;CODE class=" language-sas"&gt;exch_usd&lt;/CODE&gt;. It appears Proc Import is struggling with the European style comma as decimal separator - at least when executing with a non-European local. I've applied the required change already to below code. Compare below with what you get originally (in your SAS log executing Proc Import) and you should have all the guidance on how to proceed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only thing you need to change in below code for it to execute in your environment is &lt;CODE class=" language-sas"&gt;infile '&amp;lt;path&amp;gt;/Data_projet_AFRIQUE1.txt' &lt;/CODE&gt;&amp;nbsp;to what you get in your SAS log using Proc Import.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data PREP.AFRICA;
  %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
  infile '&amp;lt;path&amp;gt;/Data_projet_AFRIQUE1.txt' delimiter = ';' MISSOVER DSD lrecl=32767 firstobs=2;
  informat case best32.;
  informat cc3 $3.;
  informat country $24.;
  informat year best32.;
  informat systemic_crisis best32.;
  informat exch_usd commax.;
  informat domestic_debt_in_default best32.;
  informat sovereign_external_debt_default best32.;
  informat gdp_weighted_default nlnum32.;
  informat inflation_annual_cpi nlnum32.;
  informat independence best32.;
  informat currency_crises best32.;
  informat inflation_crises best32.;
  informat banking_crisis $9.;
  format case best12.;
  format cc3 $3.;
  format country $24.;
  format year best12.;
  format systemic_crisis best12.;
  format exch_usd 32.10;
  format domestic_debt_in_default best12.;
  format sovereign_external_debt_default best12.;
  format gdp_weighted_default nlnum12.;
  format inflation_annual_cpi nlnum12.;
  format independence best12.;
  format currency_crises best12.;
  format inflation_crises best12.;
  format banking_crisis $9.;
  input
    case
    cc3  $
    country  $
    year
    systemic_crisis
    exch_usd  
    domestic_debt_in_default
    sovereign_external_debt_default
    gdp_weighted_default
    inflation_annual_cpi
    independence
    currency_crises
    inflation_crises
    banking_crisis  $
  ;
  if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */
run;&lt;/CODE&gt;&lt;/PRE&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>Sun, 22 Mar 2020 21:27:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/633992#M77935</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-22T21:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/634014#M77937</link>
      <description>hi ,&lt;BR /&gt;I'm beginner , so i have a question why you put &amp;lt;&amp;gt; after&lt;BR /&gt;&amp;lt;&amp;gt; ? can you explain " if _ERROR_ then call&lt;BR /&gt;symputx('_EFIERR_',1);" .?&lt;BR /&gt;thanks you.&lt;BR /&gt;</description>
      <pubDate>Sun, 22 Mar 2020 23:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/634014#M77937</guid>
      <dc:creator>ks94</dc:creator>
      <dc:date>2020-03-22T23:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/634016#M77938</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;&lt;EM&gt;why you put &amp;lt;&amp;gt;&lt;/EM&gt;&lt;/SPAN&gt;"&amp;nbsp; I guess you're talking about this bit:&amp;nbsp;&lt;SPAN&gt;infile '&lt;STRONG&gt;&amp;lt;path&amp;gt;&lt;/STRONG&gt;/Data_projet_AFRIQUE1.txt'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The bit in the &amp;lt;&amp;gt; is a placeholder and what you need to replace with the actual path in your environment (which the Proc Import generated datastep code in the SAS log will provide).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Writing it this way is inspired by &lt;A href="https://go.documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0h6cun31ihdqtn1io0sv70zh5l8.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;SAS syntax conventions&lt;/A&gt;&amp;nbsp;in the documentation (also there the brackets have a slightly different meaning).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;if _ERROR_ then call symputx('_EFIERR_',1);&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That's what Proc Import generates. As a beginner you haven't got to SAS macro variables yet - so just ignore this bit for now.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This code is normally not something people write for a SAS datastep - but because Proc Import generates such code I didn't want to remove it - but don't hesitate to delete below two lines from your code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;....
%let _EFIERR_ = 0; 
....
if _ERROR_ then call symputx('_EFIERR_',1);  
....&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 23:55:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/634016#M77938</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-22T23:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: change type of variables numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/634017#M77939</link>
      <description>&lt;P&gt;These two lines are generated by PROC IMPORT to set a macro variable for its use. You do NOT need to include those.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
  if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The text &amp;lt;path&amp;gt; in this line is just to remind you to replace that with the actual name of the file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  infile '&amp;lt;path&amp;gt;/Data_projet_AFRIQUE1.txt' delimiter = ';' MISSOVER DSD lrecl=32767 firstobs=2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Path is computerese for directory or folder.&amp;nbsp; You need to use the full name of the file so the INFILE statement can find the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do NOT use the code generated by PROC IMPORT as if it is a good example of how you should write your code.&amp;nbsp; It does a lot of useless (and potentially harmful) things.&amp;nbsp; Instead of defining the variables it attaching formats and informats to the variables and counts on SAS's guessing to define the variable with the right type and length based on the type and width of the format that is attached. It attaches formats and informats to variables that don't need them. It includes $ in the INPUT statement even though the variables types have already been determined before the input statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only reason to use it is because it might help you since the proc as already taken the time to figure names for the variables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 23:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/change-type-of-variables-numeric-to-character/m-p/634017#M77939</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-22T23:51:30Z</dc:date>
    </item>
  </channel>
</rss>

