Input statement ?? format modifier

Reply
Frequent Contributor
Posts: 137

Input statement ?? format modifier

Hey SAS Folks,

I would like to suppress the error message and invalid note in the log when reading a variable using the ?? modifier in the input statement. However, what if i want to use the same for many variables? Is there an easier or short cut that I can choose to use such a modifier for as many variables as i want in one shot?

A typical example would be when reading a date variable with a specific informat.

Many thanks for your help if you can.

Respected Advisor
Posts: 3,124

Re: Input statement ?? format modifier

Charlotte,

Although it may be possible to do a CodeGen manipulating text to add ?? to every single one of your numeric informat, here is trick if you have EG. Using EG to import text file (or even excel file) will generate SAS code with ??informat as default.   I have been using EG to import files ever since the first time.

Haikuo

Respected Advisor
Posts: 3,775

Re: Input statement ?? format modifier

It would help to see the input statement you have now.

Here is example that uses list input with default INFORMATS and those specified for DATE variables.

data test;
   informat a b c date9.;
  
format a b c date9.;
  
input (a x b s y c) (??);
   cards;
x y z a b 21JUL2015
x y 20JUL2015 a b 19JUN2015
x y z a b 20JUN2015
;;;;
   run;
Grand Advisor
Posts: 9,576

Re: Input statement ?? format modifier

Charlotte,

Try this one :

Code: Program

data test;
   informat a b c date9.;
   format a b c date9.;
   input a x b s y c;
   _error_=0;
   cards;
x y z a b 21JUL2015
x y 20JUL2015 a b 19JUN2015
x y z a b 20JUN2015
;;;;
   run;


Log: Program

Notes (16)

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

53 

54 data test;

55 informat a b c date9.;

56 format a b c date9.;

57 input a x b s y c;

58 _error_=0;

59 cards;

NOTE: Invalid data for a in line 60 1-1.

NOTE: Invalid data for x in line 60 3-3.

NOTE: Invalid data for b in line 60 5-5.

NOTE: Invalid data for s in line 60 7-7.

NOTE: Invalid data for y in line 60 9-9.

NOTE: Invalid data for a in line 61 1-1.

NOTE: Invalid data for x in line 61 3-3.

NOTE: Invalid data for s in line 61 15-15.

NOTE: Invalid data for y in line 61 17-17.

NOTE: Invalid data for a in line 62 1-1.

NOTE: Invalid data for x in line 62 3-3.

NOTE: Invalid data for b in line 62 5-5.

NOTE: Invalid data for s in line 62 7-7.

NOTE: Invalid data for y in line 62 9-9.

NOTE: The data set WORK.TEST has 3 observations and 6 variables.

NOTE: DATA statement used (Total process time):

  real time 0.00 seconds

  cpu time 0.01 seconds

  

Respected Advisor
Posts: 3,775

Re: Input statement ?? format modifier

Close but I think you need option ERRORS=0 to suppress the invalid data messages.


options errors=0;
data test;
   informat a b c date9.;
  
format a b c date9.;
  
input a x b s y c;
   _error_=0;
  
cards;
x y z a b 21JUL2015
x y 20JUL2015 a b 19JUN2015
x y z a b 20JUN2015
;;;;
   run;

24         options errors=0;
25         data test;
26            informat a b c date9.;
27            format a b c date9.;
28            input a x b s y c;
29            _error_=0;
30            cards;

NOTE:
The data set WORK.TEST has 3 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time          
0.00 seconds
      cpu time           
0.00 seconds
Frequent Contributor
Posts: 137

Re: Input statement ?? format modifier

Thank you super stars John and Xia Keshan as always for your help. Let me test the same tomorrow at work and acknowledge as it is too late right now in England. I appreciate it so much.

Ask a Question
Discussion stats
  • 5 replies
  • 202 views
  • 1 like
  • 4 in conversation