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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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