<?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: Datatype conversion after proc import in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Datatype-conversion-after-proc-import/m-p/623023#M183323</link>
    <description>&lt;P&gt;From which type of file are you importing?&lt;/P&gt;
&lt;P&gt;And why do you convert to numeric when age is already numeric (vtype() = 'N')?&lt;/P&gt;</description>
    <pubDate>Fri, 07 Feb 2020 12:18:13 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-02-07T12:18:13Z</dc:date>
    <item>
      <title>Datatype conversion after proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-conversion-after-proc-import/m-p/622996#M183314</link>
      <description>&lt;P&gt;HI All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my scenario - I am using proc import , which will set the datatype based on its content , hence I have taken a copy of dataset using 'set' and tried to convert the datatype using only if it satisfies my 'if logic', but it seems still goes in to the if condition even though it doesn't satisfy my condition .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below sample code , please help out how can I fix this .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: variable inside if not supposed to be created as it doesn't pass the criteria ..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
infile cards dlm=',' missover;
input name : $32. age $ ;
cards;
hawking ,20
einstein , 40
carl sagan , 30
;
run;

data dummy;
set A;
if vtype(age) = 'N' then do ;
age_1 =  input(age,best.) ;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Feb 2020 10:14:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-conversion-after-proc-import/m-p/622996#M183314</guid>
      <dc:creator>arunrami</dc:creator>
      <dc:date>2020-02-07T10:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype conversion after proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-conversion-after-proc-import/m-p/623005#M183318</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200330"&gt;@arunrami&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest that you use conditional processing with %if %then %end because the type is not a function at the "row" level but a metadata&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select upcase(type) into: type_age trimmed from dictionary.columns
	where libname='WORK' and memname = 'A' and name='age';
quit;

%if "&amp;amp;type_age"="NUM" %then %do ;
	data dummy;
		set A;
		age_1 =  input(age,best.) ;
	run;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2020 11:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-conversion-after-proc-import/m-p/623005#M183318</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-07T11:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype conversion after proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-conversion-after-proc-import/m-p/623023#M183323</link>
      <description>&lt;P&gt;From which type of file are you importing?&lt;/P&gt;
&lt;P&gt;And why do you convert to numeric when age is already numeric (vtype() = 'N')?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2020 12:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-conversion-after-proc-import/m-p/623023#M183323</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-07T12:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype conversion after proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-conversion-after-proc-import/m-p/623096#M183365</link>
      <description>It was just for an example , age is already a char variable , hence my point is , it should not enter in to if logic as it is not satisfying the logic if vtype() = 'N'.&lt;BR /&gt;&lt;BR /&gt;But still its creating variable declared in side if - do..?I wanna know why is it and how PDV works in this case?&lt;BR /&gt;&lt;BR /&gt;*I am using csv file as input</description>
      <pubDate>Fri, 07 Feb 2020 16:06:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-conversion-after-proc-import/m-p/623096#M183365</guid>
      <dc:creator>arunrami</dc:creator>
      <dc:date>2020-02-07T16:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype conversion after proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-conversion-after-proc-import/m-p/623109#M183368</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200330"&gt;@arunrami&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;HI All,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my scenario - I am using proc import , which will set the datatype based on its content , hence I have taken a copy of dataset using 'set' and tried to convert the datatype using only if it satisfies my 'if logic', but it seems still goes in to the if condition even though it doesn't satisfy my condition .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Reliance on Proc import, especially if reading data sources that are text such as CSV, is a poor practice. If you know you are going&amp;nbsp; be reading same structured data, which is sort of implied by fixing specific named variables, then better is to read them correctly in the first place using a data step. Then you control the value types at the beginning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2020 16:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-conversion-after-proc-import/m-p/623109#M183368</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-02-07T16:39:30Z</dc:date>
    </item>
  </channel>
</rss>

