Help using Base SAS procedures

Help with infile/input giving me an empty dataset

Accepted Solution Solved
Reply
N/A
Posts: 1
Accepted Solution

Help with infile/input giving me an empty dataset

Hello all-

I am quite new to SAS (I actually learned the basics some years ago but have since not needed to use the software) and am having trouble running a program that was provided by another researcher to input and clean their dataset (both the programs and data are publicly available). I have tried to adapt the initial commands to direct to where I have put the datasets, but when I run the program I end up with a dataset which has all the variable names but is empty!! Below is the initial part of the code. My procees has been:

1) download the file dist91.data.gz from the source

2) place this file in C:\temp\ directory

3) Change the "libname "statement below to read : libname sasdata 'C:\temp';

4) hit "run"

5) end up with an empty dataset.

6) I have also tried the same as above and also unzipping the .gz file into its raw .dat format, and changing the filename statement to read: filename indata91  'dist91.dat';

7) same thing happens.

As far as I know, this code was written in 2003 and possibly not changed or debugged for newer releases of SAS? I am currently running SAS 9.1 on a Windows 7 based PC. I am probably missing some important syntax, or the code was written for UNIX?

The data and programs are downloadable here: http://www.bsos.umd.edu/socy/vanneman/districts/files/index.html

I am in need to processing the 1991 data to support an academic research grant application, and can't even get this first piece done. Any thoughts or help most appreciated!

_______________________________________Begin SAS code:

/* Users will need to create their own libname and filename commands

   as appropriate for their local computer system

*/

libname  sasdata '.';

filename indata91  pipe 'gunzip -c dist91.data.gz';

data sasdata.dist91 (label='Indian 1991 districts: from dist91.dat');

    /* These temporary variables are used only to check

       correct order of input data file */

    drop rec140 rec160 rec300 rec340 rec620 rec650 rec670 rec690 ;

    attrib DLABEL length = $ 28;

infile indata91 ;

input

/*000*/  /* label record */ 

   stateid  $ 1-2

   distid   $ 3-4

   rec000     5-7 

   year       8-9 

   version     10 

   dlabel &

  /* Total Population */ 

/ /*100*/  pop  11-19  rural 20-28  male  29-37  Rmale  38-46

Attachment
Attachment
Attachment

Accepted Solutions
Solution
‎06-26-2011 07:38 PM
Frequent Contributor
Frequent Contributor
Posts: 94

Help with infile/input giving me an empty dataset

The default looks like it's set up for a unix based system, or at least where "gunzip" is available (which you can get for Windows too).

I managed to get it to run by following your instructions, but changing the libname and filename statements as below (with the data file unzipped manually).

libname  sasdata 'C:\temp\';

filename indata91 'C:\temp\dist91.dat';

Hope that helps!

View solution in original post


All Replies
Solution
‎06-26-2011 07:38 PM
Frequent Contributor
Frequent Contributor
Posts: 94

Help with infile/input giving me an empty dataset

The default looks like it's set up for a unix based system, or at least where "gunzip" is available (which you can get for Windows too).

I managed to get it to run by following your instructions, but changing the libname and filename statements as below (with the data file unzipped manually).

libname  sasdata 'C:\temp\';

filename indata91 'C:\temp\dist91.dat';

Hope that helps!

☑ This topic is SOLVED.

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

Discussion stats
  • 1 reply
  • 192 views
  • 0 likes
  • 2 in conversation