Help using Base SAS procedures

proc Import: SAS 9.3 vs. SAS 9.4

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 144
Accepted Solution

proc Import: SAS 9.3 vs. SAS 9.4

Hi everyone,

 

I'm testing some programs that we have to check if we can upgrade sas without many troubles. In a check that I was doing I notice that SAS 9.4 import different that SAS 9.3 with proc import. I have attatched the file (notice that it's in txt because communitie don't allow csv).

 

The code that I use to import in that case is

 

proc import datafile="XXXXXXX\example.csv"         
	out=example
        dbms=csv
        replace;
     getnames=yes;
run;

 

In fact, with SAS 9.4 I get an error because sas try to put a date format into the data _NULL_.

 

Anyone know how to solve it without change importation to data _NULL_?

 

Thanks!


Accepted Solutions
Solution
‎06-29-2016 03:37 AM
Super User
Super User
Posts: 6,502

Re: proc Import: SAS 9.3 vs. SAS 9.4

Raise the issue with SAS support.  I suspect what is happening is that SAS 9.3 did not consider the value in the last row as a valid DATE format so it just reads the field as character.  But 9.4 decides that you intended the field to be a date.

 

The real solution is to only used PROC IMPORT for quick and dirty looks at source files. Once you figure out what format your input files use then write you own data step to read it.

 

If you really have no idea what is in your file then just read everything as character and take a look yourself.

 

data sample ;
  infile 'myfile' dsd truncover firstobs=2;
  length var1-var20 $200 ;
  input var1-var20;
run;

View solution in original post


All Replies
Super User
Posts: 17,912

Re: proc Import: SAS 9.3 vs. SAS 9.4

You don't have control with proc import. Unless you write your own data step you can't control the variable type from a text file. 

You can try GuessingRows=1 but that might mess up other things. 

Solution
‎06-29-2016 03:37 AM
Super User
Super User
Posts: 6,502

Re: proc Import: SAS 9.3 vs. SAS 9.4

Raise the issue with SAS support.  I suspect what is happening is that SAS 9.3 did not consider the value in the last row as a valid DATE format so it just reads the field as character.  But 9.4 decides that you intended the field to be a date.

 

The real solution is to only used PROC IMPORT for quick and dirty looks at source files. Once you figure out what format your input files use then write you own data step to read it.

 

If you really have no idea what is in your file then just read everything as character and take a look yourself.

 

data sample ;
  infile 'myfile' dsd truncover firstobs=2;
  length var1-var20 $200 ;
  input var1-var20;
run;
Frequent Contributor
Posts: 144

Re: proc Import: SAS 9.3 vs. SAS 9.4

Ok, thanks for the information. I will create a issue in SAS support and try to upgrade to data step the imports that give problems in SAS 9.4 and not in 9.3
Frequent Contributor
Posts: 144

Re: proc Import: SAS 9.3 vs. SAS 9.4

Hi,
I have spoke with support and seems to be an error with SAS 9.4. TS1M3, the same importation in M2 don't give any error. They say that may be solved on next version.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 482 views
  • 0 likes
  • 3 in conversation