BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ydu180
Calcite | Level 5
libname project "/home/ydu180/project";
title1"Project";

data project.ydu_18;
   infile "/home/ydu180/project/housing.data" dlm='09'x dsd truncover;
   input CRIM ZN INDUS CHAS NOX RM AGE DIS RAD TAX PTRATIO B LSTAT MEDV;
   format CRIM 8.5
          ZN 5.2 
          INDUS 6.3
          CHAS 1.0
          NOX 6.4
          RM 6.4
          AGE 5.2 
          DIS 7.4
          RAD 2.0 
          TAX 5.1
          PTRATIO 5.2
          B 6.2
          LSTAT 5.2
          MEDV 5.2;
   Label CRIM="per capita crime rate by town"
         ZN="proportion of residential land zoned for lots over 25,000 sq.ft."
         INDUS="proportion of non-retail business acres per town"
         CHAS="Charles River dummy variable (= 1 if tract bounds river; 0 otherwise)"
         NOX="nitric oxides concentration (parts per 10 million)"
         RM="average number of rooms per dwelling"
         AGE="proportion of owner-occupied units built prior to 1940 "
         DIS="weighted distances to five Boston employment centres"
         RAD="index of accessibility to radial highways"
         TAX="full-value property-tax rate per $10,000"
         PTRATIO="pupil-teacher ratio by town"
         B="1000(Bk - 0.63)^2 where Bk is the proportion of blacks by town"
         LSTAT="% lower status of the population"
         MEDV="Median value of owner-occupied homes in $1000's";
run;

proc contents data=project.ydu_18;
run;

proc print data=project.ydu_18 label noobs;
   var CRIM ZN INDUS CHAS NOX RM AGE DIS RAD TAX PTRATIO B LSTAT MEDV;
run;

There are 506 instances for every 14 variables, so the total observations should be 7084. I got 506 rows and 14 columns, but there were all dots, which is like the following. 

微信图片_20170708011734.png

The content shows I only have 506 observations. The source data website is http://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data   

Could someone tell how I read this txt and can get those data shown on my results?

1 ACCEPTED SOLUTION

Accepted Solutions
SuzanneDorinski
Lapis Lazuli | Level 10

Your code assumes that the file uses a tab as the delimiter.  But the file uses spaces as the delimiter.

 

The DSD option in the infile statement will treat consecutive delimiters as a missing value.  You don't want that, because the values in the file are separated by two or three spaces.  

 

Try

 

infile "/home/ydu180/project/housing.data";

instead.

 

Can you read this into SAS® for me? “Using INFILE and INPUT to Load Data Into SAS® has lots of examples of reading external files into SAS.

 

View solution in original post

2 REPLIES 2
SuzanneDorinski
Lapis Lazuli | Level 10

Your code assumes that the file uses a tab as the delimiter.  But the file uses spaces as the delimiter.

 

The DSD option in the infile statement will treat consecutive delimiters as a missing value.  You don't want that, because the values in the file are separated by two or three spaces.  

 

Try

 

infile "/home/ydu180/project/housing.data";

instead.

 

Can you read this into SAS® for me? “Using INFILE and INPUT to Load Data Into SAS® has lots of examples of reading external files into SAS.

 

ydu180
Calcite | Level 5
Got that, thank you so much. As one of my assignment that data has spaces but use dlm="09"x, then I thought this will be the same. Thanks again.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 1525 views
  • 1 like
  • 2 in conversation