BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Is there a way that I can have SAS check each variable to determine if it should be character, or numeric and the appropraite length? I currently use the import wizard then copy from the log and modify it as needed, but with many files to read in, this get very time consuming.

Thanks
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi,
There is a GUESSINGROWS option, but I can't remember whether it is for the LIBNAME engine or PROC IMPORT. You could check with the doc or with Tech Support.

cynthia
deleted_user
Not applicable
If you are using a wizard in Enterprise Guide or something else, it will be a tedious chore for you. I usually read CSV files with custom-written SAS code that validates all values.

I read in all numeric and date values as character with names such as START_DATE_CHAR, ACCOUNT_NUMBER_CHAR, and so on. Then I check each one like this:

infile
"account_info.csv" dsd firstobs=1 lrecl=400 missover print;

input
account_number_char $10.
start_date_char $15.;

if compress(start_date_char) ne '' then
start_date = input(start_date_char, ddmmyy10.);
else
start_date = .;

if compress(account_number_char) not in ('-', '?', '') then
account_number = input(account_number_char, 8.);
else
account_number = 0;

Then DROP the _CHAR variables. In this manner, you can trap any data exception from Excel and handle it exactly the way you want. You can also check field lengths. But you'll need to write SAS code. Message was edited by: Roddy

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 2 replies
  • 655 views
  • 0 likes
  • 2 in conversation