DATA Step, Macro, Functions and more

proc import problem

Not applicable
Posts: 0

proc import problem


is there any possibility to change informats , while i am importing text file into datasets using proc import.

text file contains 300 variables.
Valued Guide
Posts: 2,191

Re: proc import problem

Posted in reply to deleted_user
although a variable can have only one informat declared in a data set, in a data step it can have a different informat every time it appears on an input statement.
With the INPUTN() function, it could have a different informat every time the function is executed!
Of course these levels of flexibility disappear in PROC IMPORT :-(

I recommend making the DATA STEP your friend.

Respected Advisor
Posts: 3,852

Re: proc import problem

Posted in reply to deleted_user
Assuming you are referring to TEXT files CSV, TXT etc. you can easily run PROC IMPORT and cut and paste the "generated code". Then you can change the informat by editing the existing INFORMAT statements. Or by adding additional statements, where you can use "SAS Variable Lists" to make short work of 300 variables. Or as was suggested you can modify the INPUT statement to include INFORMATS.

data TEST;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile FT15F001 delimiter = ',' MISSOVER DSD firstobs=2 ;
informat a $1. ;
informat b $1. ;
informat c $1. ;
format a $1. ;
format b $1. ;
format c $1. ;

informat a--b $upcase1.; * added to change INFORMAT;
** NO need to bother the statements above unless the TYPE is changed.;

a $
b $
c $

if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */
proc contents varnum;
proc print;
Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation