BookmarkSubscribeRSS Feed
LearnByMistk
Obsidian | Level 7

How to check tab delimited file metadata before importing in sas via proc import ,I mean suppose I write a proc import with columns a,b,c with their informat and format in place but in second data refresh if I get a new column D ,how to check it before proc import fails.

3 REPLIES 3
Kurt_Bremser
Super User

proc import (most probably) won't fail, as it always does its best to make sense of input data, but the result will not match your previous results (structurally).

The proper method for handling such issues is that you have an agreement in place where the structure of files is described, and the agreement has to be changed and communicated so that import steps can be adapted. Production import steps have to be data steps that have the file structure hardcoded, no proc import there.

andreas_lds
Jade | Level 19

Afaik tab-delimited files don't have any metadata in them.

Proc import does not allow to set (in)formats, so you will have to use a data step.

Tom
Super User Tom
Super User

You can read the header line and check.

Say your input file is NEWCSV and expected structure is described by the SAS datasets TEMPLATE.

* Read headers from new delimited file ;
data new_names ;
  length name $50 ;
  infile newcsv obs=1 dsd dlm='09'x ;
  input name @@ ;
run;

* Get names from template structure ;
proc transpose data=template(obs=0) out=old_names;
  var _all_;
run;

* Compare;
proc compare data=old_names compare=new_names;
run;

PROC COMPARE will actually set a macro variable you can test to see if there are differences.  Or you can use some other methods to compare.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 605 views
  • 2 likes
  • 4 in conversation