BookmarkSubscribeRSS Feed
joemvcnj
Calcite | Level 5
An SPSS file has established lengths for all character fields. However, they all default to 2000 characters as Length, Informat, and Format once imported via Proc Import or Import Wizard.
 
The only way I found to get the proper length into SAS is to open the file as SPSS and do Save As with file type .sas7bdat and saving with save value labels box checked off.
 
Is there anyway to have Proc Import give me the proper field sizes ?
6 REPLIES 6
ChrisNZ
Tourmaline | Level 20

Have you searched before posting?

Have you seen this?

joemvcnj
Calcite | Level 5

That doesn't work. That has to do with Formats and Value Labels (which I don't need), not Length.

 

Without Fmtlib statement, It deciphers numeric and character fields just fine. With it added, all character field lengths are still 2000, as are Informat and Format, which are probably derived from Length, and not carried over from SPSS.

 

I also tried the Import Wizard and saved the SAS Program it created to run later in Background after the PROC Import step. That does not do the job either.

 

This is PC-based SAS 9.4 on Windows, not Enterprise SAS.

ChrisNZ
Tourmaline | Level 20

>Without Fmtlib statement, It deciphers numeric and character fields just fine. With it added, all character field lengths are still 2000, 

 

Show us the code please.

joemvcnj
Calcite | Level 5

/* PROGRAM 1_000_Import_from_SPSS */

OPTION SYMBOLGEN;
%LET CCYY = 2018;
%LET MMDD = 0926;    

LIBNAME  S            "S:\Encrypt - S Drive\DM_Work\Temp_Joe_Versaggi\NJCAT3\&CCYY._&MMDD.";

FILENAME NEWCASES    "S:\Encrypt - S Drive\DM_Work\Temp_Joe_Versaggi\NJCAT3\&CCYY._&MMDD.\
NJCAT 3 Processed Data (2018-09-25 Download) - New Cases (96)
.sav";

PROC IMPORT
DATAFILE=NEWCASES
    OUT=S.pgm_001_New__&ccyy.&mmdd.
    DBMS=SPSS REPLACE;
    FMTLIB = WORK.FORMATS;

RUN;

/* END PROGRAM 1_000 */


Tom
Super User Tom
Super User

You are using DBMS=SPSS.  The article that someone linked above used DBMS=SAV.

joemvcnj
Calcite | Level 5

The result is exactly the same. Length = 2000, Informat and Format $2000 of all character fields.

 

PROC IMPORT
14   DATAFILE=NEWCASES
15       OUT=S.pgm_001_New__&ccyy.&mmdd.
SYMBOLGEN:  Macro variable CCYY resolves to 2018
SYMBOLGEN:  Macro variable MMDD resolves to 0926
16       DBMS=SAV REPLACE;
17       FMTLIB = WORK.FORMATS;
18
19   RUN;

NOTE: The import data set has 96 observations and 388 variables.
NOTE: S.PGM_001_NEW__20180926 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           1.43 seconds
      cpu time            0.31 seconds

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 6 replies
  • 1020 views
  • 0 likes
  • 3 in conversation