BookmarkSubscribeRSS Feed
Nupur20
Calcite | Level 5

Hi,

I am trying to import multiple excel files using the code below. There is a column in each excel file that has both numeric and text values but proc import is only importing numeric values, and put the text values as blank ('.').

Can anyone help with me this issue. I would greatly appreciate your time and suggestions.

%let subdir=S:\Temp\; 

filename dir "&subdir.*.xls";

data new;

length filename  fname $ 32767;

infile dir  eof=last filename=fname;

input ;

last: filename=fname;

run;

proc sort data=new nodupkey;

by filename;

run;

data null;

set new end=last;

call symputx(cats('filename',_n_),filename);

call symputx(cats('dsn',_n_),scan(scan(filename,7,'\'),1,'.'));

if last then call symputx('nobs',_n_);

run;

%put &nobs;

%macro import;

%do i=1 %to &nobs;

proc import datafile="&&filename&i" out=&&dsn&i

dbms=excel replace;

sheet = "Sheet1";

getnames=yes;

mixed=yes;

run;

%end;

%mend import;

%import

1 REPLY 1
1zmm
Quartz | Level 8

Look at the SAS documentation for PROC IMPORT.  Specifying a larger value in its new option, GUESSINGROWS, may solve this problem for you.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1459 views
  • 0 likes
  • 2 in conversation