<?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 How to change formats/datatyps? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-formats-datatyps/m-p/719312#M222716</link>
    <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to change a datetyp of column and I'm not sure if this is the correct way to do this. I mean my solution works, but is their a possibility to define the new datatyp directly in the attrib function? Maybe with the informat definition. I'm not really sure what informat is and when I should use this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data inputData;
	input	
		name 	$
		amount	$;
	datalines;
		Peter 100
		Kai 25
	;
run;

data outputData;
	attrib	
		name 	format = $10.
		amount  format = $10.
		/* amount informat = $10. format 10.*/
	;
	set inputData;
	amount_tmp = input(amount, 10.);
	drop amount;
	rename amount_tmp = amount;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hans&lt;/P&gt;</description>
    <pubDate>Mon, 15 Feb 2021 10:59:48 GMT</pubDate>
    <dc:creator>Hansmuffs</dc:creator>
    <dc:date>2021-02-15T10:59:48Z</dc:date>
    <item>
      <title>How to change formats/datatyps?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-formats-datatyps/m-p/719312#M222716</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to change a datetyp of column and I'm not sure if this is the correct way to do this. I mean my solution works, but is their a possibility to define the new datatyp directly in the attrib function? Maybe with the informat definition. I'm not really sure what informat is and when I should use this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data inputData;
	input	
		name 	$
		amount	$;
	datalines;
		Peter 100
		Kai 25
	;
run;

data outputData;
	attrib	
		name 	format = $10.
		amount  format = $10.
		/* amount informat = $10. format 10.*/
	;
	set inputData;
	amount_tmp = input(amount, 10.);
	drop amount;
	rename amount_tmp = amount;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hans&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 10:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-formats-datatyps/m-p/719312#M222716</guid>
      <dc:creator>Hansmuffs</dc:creator>
      <dc:date>2021-02-15T10:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to change formats/datatyps?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-formats-datatyps/m-p/719315#M222717</link>
      <description>You do need to jump through the drop/rename hoop.  However, the program works without the attrib statement.  That can be removed.&lt;BR /&gt;&lt;BR /&gt;Also note, the top DATA step assigns AMOUNT a length of $8.  If that's the case (and I realize your post might be a simplification of your actual program), your solution still works.  But you need to read only 8 characters  not 10 in the formula for AMOUNT_TMP.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Feb 2021 11:35:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-formats-datatyps/m-p/719315#M222717</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-02-15T11:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to change formats/datatyps?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-formats-datatyps/m-p/719316#M222718</link>
      <description>&lt;P&gt;Why is it necessary to change the variable type? I would fix the importing process. If that can't be done, using the input-function is the way to go.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 11:39:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-formats-datatyps/m-p/719316#M222718</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-02-15T11:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to change formats/datatyps?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-formats-datatyps/m-p/719318#M222720</link>
      <description>&lt;P&gt;I need to change datatype from character to numeric.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I change dataype from format 10. to 8. maybe when I have long numbers 12345678910 some numbers at the end will be cut?!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data outputData_V3;
	set inputData;
	amount = input(amount, 8.);
	amount_final = input(amount, 8.);
	drop amount;
	rename amount_final = amount;
run;&lt;/PRE&gt;&lt;P&gt;I don't know how to change the datatyp without drop and rename because as you can see amount = input(amount, 8.) will not create a numeric value it is still character. But the amount_final is in numeric format.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 12:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-formats-datatyps/m-p/719318#M222720</guid>
      <dc:creator>Hansmuffs</dc:creator>
      <dc:date>2021-02-15T12:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to change formats/datatyps?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-formats-datatyps/m-p/719342#M222734</link>
      <description>&lt;P&gt;OK, let's go back to your original program, with ATTRIB cut out:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data inputData;
	input	
		name 	$
		amount	$;
	datalines;
Peter 100
Kai 25
;

data outputData;
	set inputData;
	amount_tmp = input(amount, 10.);
	drop amount;
	rename amount_tmp = amount;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This should work.&amp;nbsp; Yes, this never works:&amp;nbsp; amount = input(amount, 10.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The top DATA step gives AMOUNT a length of $8.&amp;nbsp; It could never store "1234567890".&amp;nbsp; In real life, that may not be how AMOUNT got created, so it may actually have a longer length.&amp;nbsp; Within the INPUT function, use whatever length is actually assigned to AMOUNT.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 14:15:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-formats-datatyps/m-p/719342#M222734</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-02-15T14:15:22Z</dc:date>
    </item>
  </channel>
</rss>

