Write and run SAS programs in your web browser

Cannot show read results

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

Cannot show read results

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?


Accepted Solutions
Solution
‎07-07-2017 06:47 PM
Frequent Contributor
Posts: 89

Re: Cannot show read results

[ Edited ]

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


All Replies
Solution
‎07-07-2017 06:47 PM
Frequent Contributor
Posts: 89

Re: Cannot show read results

[ Edited ]

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.

 

Contributor
Posts: 23

Re: Cannot show read results

Posted in reply to SuzanneDorinski
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.
☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 207 views
  • 1 like
  • 2 in conversation