<?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: Reference column type in data step OR suppress invalid numeric data message in log in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reference-column-type-in-data-step-OR-suppress-invalid-numeric/m-p/856598#M338459</link>
    <description>&lt;P&gt;I would use an informat to take care of that, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue asterix
    '*'=.
    other=best12.;
run;
data one; 
   informat a asterix.;                    
   input ID A;     
   datalines;          
2477 195 
2431 220 
2456 173 
2412 135 
; 
run;
data two;                     
   informat a asterix.;  
   input ID A ;     
   datalines;          
3777  *  
9731  *  
7756  110
2712  * 
;  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You wouldn't need more than one datastep, though. Just assign the infiles you want to read with a single filename, e.g.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename data_in ('c:\indata\*.dat','d:\test.dat');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or just use wildcards, as shown, if that is enough. And then just this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one; 
   informat a asterix.; 
   infile data_in;                   
   input ID A;     
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 01 Feb 2023 09:28:28 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2023-02-01T09:28:28Z</dc:date>
    <item>
      <title>Reference column type in data step OR suppress invalid numeric data message in log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reference-column-type-in-data-step-OR-suppress-invalid-numeric/m-p/856459#M338406</link>
      <description>&lt;P&gt;I'm reading in multiple files that need to be stacked into a single dataset. In some files, column A contains all numeric values. In other files,&amp;nbsp; an * appears when numeric values are missing, defining the column type as character. I have a data step that sets * to missing and then creates a new numeric column using the input function. Is there a way to reference column type as part of a do statement where the data step executes only when the column type is character? Alternatively, is there a way to suppress "Invalid numeric data, '*'" message from the log?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data one;                     
   input ID A;     
   datalines;          
2477 195 
2431 220 
2456 173 
2412 135 
; 
run;
data two;                     
   input ID A $;     
   datalines;          
3777  *  
9731  *  
7756  110
2712  * 
;  
run;
data stacked;
	set _null_;
run;
%macro make_num(set);
	data &amp;amp;set;
		set &amp;amp;set;
		if A = "*" then A = "";
		A_Num = input(A, best12.);
	run;
	data stacked;
		set stacked &amp;amp;set (drop = A);
	run;
%mend;
%make_num(one);
%make_num(two);&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 13:17:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reference-column-type-in-data-step-OR-suppress-invalid-numeric/m-p/856459#M338406</guid>
      <dc:creator>mmm7</dc:creator>
      <dc:date>2023-01-31T13:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Reference column type in data step OR suppress invalid numeric data message in log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reference-column-type-in-data-step-OR-suppress-invalid-numeric/m-p/856464#M338408</link>
      <description>&lt;P&gt;In my 35 years of datastep programming I never considered an infile option for alternative missing characters. But now I see a need for that. But there is none.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why would you have two sets of code? You can use your code for dataset TWO for ONE as well. Much easier. I gues the computing overhead would be minimal and not outweigh the ease of having one piece of code. and no need for going over your data twice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one_two;
	length id 8 a_char $12 a 8;
	input id a_char $;
	drop a_char;
	if a_char = '*' then a = .;
	else a = input(a_char, best12.);
	datalines;
...
run;      &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jan 2023 13:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reference-column-type-in-data-step-OR-suppress-invalid-numeric/m-p/856464#M338408</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2023-01-31T13:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Reference column type in data step OR suppress invalid numeric data message in log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reference-column-type-in-data-step-OR-suppress-invalid-numeric/m-p/856598#M338459</link>
      <description>&lt;P&gt;I would use an informat to take care of that, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue asterix
    '*'=.
    other=best12.;
run;
data one; 
   informat a asterix.;                    
   input ID A;     
   datalines;          
2477 195 
2431 220 
2456 173 
2412 135 
; 
run;
data two;                     
   informat a asterix.;  
   input ID A ;     
   datalines;          
3777  *  
9731  *  
7756  110
2712  * 
;  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You wouldn't need more than one datastep, though. Just assign the infiles you want to read with a single filename, e.g.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename data_in ('c:\indata\*.dat','d:\test.dat');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or just use wildcards, as shown, if that is enough. And then just this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one; 
   informat a asterix.; 
   infile data_in;                   
   input ID A;     
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Feb 2023 09:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reference-column-type-in-data-step-OR-suppress-invalid-numeric/m-p/856598#M338459</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2023-02-01T09:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Reference column type in data step OR suppress invalid numeric data message in log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reference-column-type-in-data-step-OR-suppress-invalid-numeric/m-p/856605#M338461</link>
      <description>&lt;P&gt;Yeah I 100% support the use of an informat. I completely overlooked the obvious solution in my earlier reply.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 10:37:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reference-column-type-in-data-step-OR-suppress-invalid-numeric/m-p/856605#M338461</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2023-02-01T10:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: Reference column type in data step OR suppress invalid numeric data message in log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reference-column-type-in-data-step-OR-suppress-invalid-numeric/m-p/856806#M338527</link>
      <description>&lt;P&gt;On a second thought, my first attempt permanently assigns an informat to the A variable. And you may have problems with that later, if you do not save the informat in a permanent library, which you probably do not want to, as it is just for this special purpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you would probably rather want to use something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one; 
   infile data_in;                   
   input ID A : asterix.;     
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in the final data step.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 10:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reference-column-type-in-data-step-OR-suppress-invalid-numeric/m-p/856806#M338527</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2023-02-02T10:41:14Z</dc:date>
    </item>
  </channel>
</rss>

