BookmarkSubscribeRSS Feed
Miah
Obsidian | Level 7

I am having trouble importing this data set into SAS. It is a tab delimited file, that also contains " in the title names and date data. How can I fix it? Here it is my code, and right after it is the error message that I am getting: 

 

proc import datafile="/folders/myfolders/KCHomes.txt"
REPLACE;
DELIMITER='09'x;
GETNAMES=YES;
run;

DATA KCHomes;
RUN;

 

 

ERROR:

The table "WORK.KCHOMES" cannot be opened because it does not contain any columns

2 REPLIES 2
Patrick
Opal | Level 21

@Miah

A very quick and easy way to import such data is to use the EG (or SAS Studio) import wizard. This will generate the code for you and the only thing you have to change in this generated code is the file path and the delimiter.

 

Here how such generated code looks like:


DATA WORK.KCHomes;
    LENGTH
        date               8
        price              8
        bedrooms           8
        bathrooms          8
        sqft_living        8
        waterfront       $ 3
        condition          8
        grade              8
        yr_built           8 ;
    FORMAT
        date             MMDDYY10.
        price            BEST7.
        bedrooms         BEST1.
        bathrooms        BEST4.
        sqft_living      BEST4.
        waterfront       $CHAR3.
        condition        BEST1.
        grade            BEST2.
        yr_built         BEST4. ;
    INFORMAT
        date             MMDDYY10.
        price            BEST7.
        bedrooms         BEST1.
        bathrooms        BEST4.
        sqft_living      BEST4.
        waterfront       $CHAR3.
        condition        BEST1.
        grade            BEST2.
        yr_built         BEST4. ;
    INFILE 'C:\temp\KCHomes.txt'
        firstobs=2
        LRECL=43
        ENCODING="WLATIN1"
        TERMSTR=CRLF
        DLM='09'x
        MISSOVER
        DSD ;
    INPUT
        date             : ?? MMDDYY10.
        price            : ?? BEST7.
        bedrooms         : ?? BEST1.
        bathrooms        : ?? COMMA4.
        sqft_living      : ?? BEST4.
        waterfront       : $CHAR3.
        condition        : ?? BEST1.
        grade            : ?? BEST2.
        yr_built         : ?? BEST4. ;
RUN;


 

 

JohnHoughton
Quartz | Level 8

Your code works for me if I just add the out= option and get rid of the bit that says " data kchomes ; run;"

 

proc import datafile="KCHomes.txt" out=kchomes
REPLACE;
DELIMITER='09'x;
GETNAMES=YES;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1398 views
  • 2 likes
  • 3 in conversation