Help using Base SAS procedures

PROC IMPORT, txt file

Not applicable
Posts: 0

PROC IMPORT, txt file


I'm trying to import a text file where some of the records for a variable are more than 700 characters long.
Proc import procedure is setting a length of 500 for that variable and my output dataset has those records being cut-off at 500th character.

Is there any way to solve this without adding a data step to the proc import??

Thanks in advance
Super Contributor
Super Contributor
Posts: 3,176

Re: PROC IMPORT, txt file

Posted in reply to deleted_user
Depending on your SAS version, there is a GUESSINGROWS= option, if you want SAS to interrogate more than the default number of rows. The SAS support website has product DOC and technical paper resources, and a SEARCH facility to find topic related info. I have provided a few links below to related items from the support site.

Scott Barry
SBBWorks, Inc.
Not applicable
Posts: 0

Re: PROC IMPORT, txt file

Dear Scott,

Thanks a lot for the reply..

I used the option GUESSINGROWS=50 (my dataset has only 25 observations),
but it didn't work out.

I used the following code that was generated by PROC IMPORT:

data TS ;
2269 %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
2270 infile 'P:\DVL_0865\Mapping\1160_0025\Trial_design_1160-0025.txt' delimiter='09'x MISSOVER DSD lrecl=32767 firstobs=2 ;
2271 informat STUDYID $9. ;
2272 informat DOMAIN $2. ;
2273 informat TSSEQ best32. ;
2274 informat TSPARMCD $10. ;
2275 informat TSPARM $46. ;
2276 informat TSVAL $500. ;
2277 format STUDYID $9. ;
2278 format DOMAIN $2. ;
2279 format TSSEQ best12. ;
2280 format TSPARMCD $10. ;
2281 format TSPARM $46. ;
2282 format TSVAL $500. ;
2283 input
2284 STUDYID $
2285 DOMAIN $
2286 TSSEQ
2288 TSPARM $
2289 TSVAL $
2290 ;
2291 if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */
2292 run;

For the variable TSVAL , I need the length to be 700.
I've copied the above program and changed the format and informat for TSVAL and it worked..

Is there any way that I can do this in PROC IMPORT STEP without adding the datastep. This is beacause, we are using the proc import step in a macro and we didn't want to have the set of variables that are in the data step.

Thanks a lot
Valued Guide
Posts: 2,191

Re: PROC IMPORT, txt file

Posted in reply to deleted_user
I think the short answer is

It's not a feature of proc import from a text file.

If you have predictable problems like that 500/700, then you probably have enough information to define the max column lengths and any special informats to be used like dates. With that information your macro needs only define which layout type is relevant and apply that.

good Luck

Super Contributor
Super Contributor
Posts: 3,176

Re: PROC IMPORT, txt file

Honestly, I would consider this to be a limit/defect for PROC IMPORT -- one that you may want to pursue with SAS Tech Support by opening a track. At least get it logged with them that you are dissatisfied with the PROC IMPORT handling of column data greater than 500 characters.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 4 replies
  • 3 in conversation