BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dlazer1
Calcite | Level 5

Hi,

 

I am unable to properly informat the date from my csv file. When I do a proc import or using the import wizard, the date is cut off to have a format of $1. and informat of $1.

 

proc import datafile='C:***********.csv'
 dbms=csv out=work.test replace;
run;

 

I have tried including "input Date MMDDYY10." in the proc import statement but it does not work.

My date format from the csv file is 12/31/2017 but it is currently only showing up as the first character or "1". 

 

Thank you for your help!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
GUESSINGROWS=MAX;

In general, PROC IMPORT guesses, and it can guess wrong. Especially if the first records it encounters are only length 1 or it has mixed values. 

 

You can set GUESSINGROWS=MAX to avoid this but it scans the whole file first which can be time consuming. In general, you're better off writing a data step with INPUT and specifying the lengths ahead of time. See the log for an example of how you would write the code or to use it as starter code and modify as needed.

 


@dlazer1 wrote:

Hi,

 

I am unable to properly informat the date from my csv file. When I do a proc import or using the import wizard, the date is cut off to have a format of $1. and informat of $1.

 

proc import datafile='C:***********.csv'
 dbms=csv out=work.test replace;
run;

 

I have tried including "input Date MMDDYY10." in the proc import statement but it does not work.

My date format from the csv file is 12/31/2017 but it is currently only showing up as the first character or "1". 

 

Thank you for your help!

 


 

View solution in original post

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

The import wizard generates code.

What does that look like? Would modifying it be a solution?

Otherwise it's hard to comment without seeing the first few lines of the CSV file.

Reeza
Super User
GUESSINGROWS=MAX;

In general, PROC IMPORT guesses, and it can guess wrong. Especially if the first records it encounters are only length 1 or it has mixed values. 

 

You can set GUESSINGROWS=MAX to avoid this but it scans the whole file first which can be time consuming. In general, you're better off writing a data step with INPUT and specifying the lengths ahead of time. See the log for an example of how you would write the code or to use it as starter code and modify as needed.

 


@dlazer1 wrote:

Hi,

 

I am unable to properly informat the date from my csv file. When I do a proc import or using the import wizard, the date is cut off to have a format of $1. and informat of $1.

 

proc import datafile='C:***********.csv'
 dbms=csv out=work.test replace;
run;

 

I have tried including "input Date MMDDYY10." in the proc import statement but it does not work.

My date format from the csv file is 12/31/2017 but it is currently only showing up as the first character or "1". 

 

Thank you for your help!

 


 

dlazer1
Calcite | Level 5

Thank you! This worked. 

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
  • 3 replies
  • 2230 views
  • 1 like
  • 3 in conversation