proc import on sas 9.2

Reply
Super Contributor
Super Contributor
Posts: 444

proc import on sas 9.2

this below is  an excel 97 file  i have imported into SAS.

After importing is done age ends up being defined as numeric.I read an article that if in the guessed rows we have char and num under the same column then automatically  that column gets defined as char.

Also guessingrows and DBDSOPTS are not working in my proc import codes. is this cuz i have SAS9.2?

namesexageHeightWeight
AlfredM1469112.5
AliceF1356.584
BarbaraF           n/a65.398
CarolF1462.8102.5
HenryM1463.5102.5
Super Contributor
Posts: 339

Re: proc import on sas 9.2

Could you provide your code? Each guessingrows and dbdsopts were existing features of 9.2 and should've provided you with means to import age as character if that was your desired input.

Super Contributor
Super Contributor
Posts: 444

Re: proc import on sas 9.2

Posted in reply to Vince28_Statcan

hey Vince

here is my code:

proc import datafile='C:\Users\Tal\Desktop\class.xls' out=new replace;

guessingrows=10;

DBDSOPTS = 'firstobs=3';  (so i have two rows of text between the column names row and the actual data i dont need into sas

run;

Super Contributor
Super Contributor
Posts: 444

Re: proc import on sas 9.2

i mean i can use mixed=yes to have age being char but it should also work without mixed=yes,no?

Super User
Posts: 11,343

Re: proc import on sas 9.2

Without Mixed it will use a default number of rows at the top of the data to assign a variable type. If all of the first rows, and I'm not sure how many that is, are numeric then the variable is assumed to be numeric.

Looking at my documentation I'm not even sure that guessingrows has any effect on excel imports.

Super Contributor
Super Contributor
Posts: 444

Re: proc import on sas 9.2

here is some text of an article posted by H Droogendyk

"Note that age is a character variable because the “N/A” value was found within the first number of rows ( i.e.
GUESSINGROWS value ) in an otherwise numeric column. If the first number of rows had all been numeric and the
“N/A” was found in a row beyond the GUESSINGROWS value, the column would have been defined as numeric and
the age value would have been set to missing for the observation with “N/A”.

So the problem here is that my n/a value was within GUESSINGROWS not beyond so i thought he talks about older verisons of SAS here

Super Contributor
Super Contributor
Posts: 444

Re: proc import on sas 9.2

if it is a csv file and  only one n/a value then age is defined as char in the output set but if it is a xls then SAS goes by whatever type has more values .That's insane!

Super User
Posts: 11,343

Re: proc import on sas 9.2

Actually has more to do with the Excel data engine than SAS.

Ask a Question
Discussion stats
  • 7 replies
  • 561 views
  • 0 likes
  • 3 in conversation