BookmarkSubscribeRSS Feed
Drianjul
Calcite | Level 5
I'm about to pull my hair out over this one. 😃

I've set up the following code:
=================
LIBNAME NH3 'E:\NHANES III\DATA';
PROC SORT DATA=NH3.EXAM;
by SEQN;
PROC SORT DATA=NH3.ADULT;
by SEQN;
DATA NH3.DEMO1_NH3;
merge NH3.EXAM
NH3.ADULT;
by SEQN;
PROC CONTENTS DATA = NH3.DEMO1_NH3 varnum;
RUN;
=============================
with the following results:
120 LIBNAME NH3 'E:\NHANES III\DATA';
NOTE: Libref NH3 was successfully assigned as follows:
Engine: V9
Physical Name: E:\NHANES III\DATA

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 10:11.61
cpu time 2.11 seconds


121 PROC SORT DATA=NH3.EXAM;
ERROR: File NH3.EXAM.DATA does not exist.
122 by SEQN;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


123 PROC SORT DATA=NH3.ADULT;
ERROR: File NH3.ADULT.DATA does not exist.
124 by SEQN;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


125 DATA NH3.DEMO1_NH3;
126 merge NH3.EXAM
127 NH3.ADULT;
ERROR: File NH3.EXAM.DATA does not exist.
ERROR: File NH3.ADULT.DATA does not exist.
128 by SEQN;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set NH3.DEMO1_NH3 may be incomplete. When this step was stopped there
were 0 observations and 0 variables.
WARNING: Data set NH3.DEMO1_NH3 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds


129 PROC CONTENTS DATA = NH3.DEMO1_NH3 varnum;
130 RUN;

NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
============================
As a sanity check - here is the file name info for the two files (using copypath):
E:\NHANES III\DATA\adult.dat
E:\NHANES III\DATA\exam.dat

=================
what am I doing wrong??
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
Here's the thing...generally, files with a file extension of .DAT are NOT SAS data sets -- they are "flat" files or "raw" data files that need to be read into SAS dataset form. SAS datasets, starting with Version 7 and higher on Windows and Unix have the file extension of SAS7BDAT -- as in CLASS.SAS7BDAT, SHOES.SAS7BDAT, etc. So if you use Windows Explorer to look at your directory of data files and you only see .DAT files and NOT SAS7BDAT files, then you must run a program to read the "flat" files into SAS form.

The NHANES site has fairly complete information on reading their data using SAS -- you should only need to find the correct SAS program -- an INFILE/INPUT program that is used to read EXAM.DAT into a SAS dataset.

After that program runs successfully, then you will be able to run your PROC SORT and do your further analysis.

Notice that in this program from the CDC, they reference EXAM.DAT in a filename statement and tell you to look for the correct INFILE program that corresponds to your data of choice:
[pre]
http://www.cdc.gov/nchs/tutorials/NHANES/downloads/NHANESIII/NH3_DownloadData_Task3.sas
************************************************************************************************
* Program: C:\NHANES III\NH3_DownloadData_Task3.sas *
* Proposal: Program to modify Filenames and assign Libnames and output to a permanent library *
************************************************************************************************;

Filename In1 "C:\NHANES III\TEMP\EXAM.DAT" LRECL=6235;
Filename In2 "C:\NHANES III\TEMP\ADULT.DAT" LRECL=3348;
Filename In3 "C:\NHANES III\TEMP\YOUTH.DAT" LRECL=2103;
Filename In4 "C:\NHANES III\TEMP\LAB.DAT" LRECL=1979;

/*remember to change your library to the directory location you downloaded your files*/
Libname NH3 "C:\NHANES III\DATA";

/*Cut and paste the SAS code provided on the website beginning with the Data step all the way through to the end.
Copy each of the four sas code files successively.
Be sure that for each one the Infile In statement is correct by specifying
Infile In1, Infile In2, Infile In3, or Infile In4 which corresponds to the SAS code you have just copied over.
Also be sure that your Data statement is also correctly specified as NH3.EXAM, NH3.ADULT, NH3.YOUTH, or NH*/

[/pre]

And then in this web site:
ftp://ftp.cdc.gov/pub/Health_Statistics/NCHS/Datasets/NHANES/NHANESIII/1A/exam.sas

They have a complete program that reads an NHANES EXAM.DAT file. Perhaps between this information and the information on the CDC site, you will be able to convert your .DAT files into SAS datasets and perform your analysis. Here's the link to the NHANES information site:
http://www.cdc.gov/nchs/about/major/nhanes/nh3data.htm

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 2015 views
  • 0 likes
  • 2 in conversation