The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Dataset use (other programs) » SAS formatting programs
SAS formatting programs [message #11093] Wed, 26 October 2016 07:48 Go to next message
mwoolf is currently offline  mwoolf
Messages: 13
Registered: March 2016
Member
Hello.
From January-June 2016, I used the individual and men's recode for my data analysis
(Version 6). I'm using Malawi, Namibia, Zambia, and Zimbabwe (2010-2014).
I was able to read this into SAS with no problem.
However, now I must use the couples data for the same 4 countries and
along with my downloads came SAS programs with formats for each data
type (IR, MR, CR, etc.).
What is the purpose of these format programs? Am I using it to create a dataset
that is different from what I downloaded? If so, I tried changing the libname in
one of the format programs to point to where my downloaded data was located and that didn't work.
I ran my data without running the format program and I retrieved 0 observations.

Please assist as I can't find guidance on the DHS website on these programs.


Doctor of Public Health student

Certificate in Global Health student

College of Public Health

University of Georgia
Re: SAS formatting programs [message #11098 is a reply to message #11093] Wed, 26 October 2016 14:55 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
Following is a response from Senior DHS SAS Specialist, Ruilin Ren:

The format is provided merely as added documentation, to explain the data, and also to help make the data more meaningful/readable, especially when producing frequencies.

Please let us know if this answers your question.
Re: SAS formatting programs [message #11099 is a reply to message #11098] Wed, 26 October 2016 15:11 Go to previous messageGo to next message
mwoolf is currently offline  mwoolf
Messages: 13
Registered: March 2016
Member
Hello,
Okay, that does help but if I want to use the
program, how should I go about using it? I'm having
trouble with the program since the original libname points
to someone else's computer. I modified the libname, and
ran the data assigning the formats.
However, I am having problems reading in the couples recode
data for Malawi (2010).


Doctor of Public Health student

Certificate in Global Health student

College of Public Health

University of Georgia
Re: SAS formatting programs [message #11103 is a reply to message #11099] Thu, 27 October 2016 05:51 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
If you downloaded the flat file, it comes with .SAS and .DAT files. The .SAS file is the SAS program to be executed in order to read the ASCII dataset and create a SAS dataset, and the .DAT file is the ASCII file used in the .SAS file. The modification of the .SAS file depends on whether a temporary or permanent SAS data set is needed. In either case, the .DAT file does not need any modification.
CREATING A PERMANENT SAS DATA SET 1.

In the LIBNAME statement (line 1 of the .SAS file), specify the path of the directory where the permanent SAS data set will be stored.

Example: LIBNAME user 'C:\COUNTRY'; To call up the format associated with the variables in the SAS data file, add the following statement in a blank line following line

1: OPTIONS FMTSEARCH=(user);

2. Create a permanent format catalog by adding the name of the library reference used in the LIBNAME statement, to the PROC FORMAT statement (in line 3) as follows: PROC FORMAT LIB = user;

In this example, a permanent format catalog will be stored in the directory called 'C:\COUNTRY'.

3. On the DATA statement line, precede the name of the data file being created with a period and the library reference name specified in the LIBNAME statement. The LIBNAME, period and data file name should form one word. DATA user.datasetname;

4. In the INFILE statement, add the path for the directory in which the .DAT file is located. INFILE 'C:\COUNTRY\datasetname.dat';

5. Add a RUN statement at the end of the .SAS file if there is no other SAS statement following the DATA step. RUN; A permanent SAS data file will be created in the specified directory, which will also contain the format catalog. The formats associated with the variables in the SAS data file are recalled in a new SAS session by adding the following statement to the SAS program: OPTIONS FMTSEARCH = (user); where user is the library reference name given in the LIBNAME statement. This statement should appear before the SAS data file is used in a DATA step or PROC statement.

CREATING A TEMPORARY SAS DATA SET

1. Delete the LIBNAME statement.

2. In the INFILE statement, add the path for the directory in which the .DAT file is located.

3. Add a RUN statement at the end of the .SAS file if there is no other SAS statement following the DATA step.

NOTE: The DATA statement (Data datasetname;) must always be on the line immediately before the very first ATTRIB statement. If the statement is at a different location, please MOVE it. Also, the default value for maximum record length is 256, but if the longest record in the dataset is greater than 256, you need to edit the INFILE statement. Please include the parameters INFILE {datasetname} LRECL={maximum record length} MISSOVER. INFILE 'C:\COUNTRY\datasetname.dat' LRECL=max.rec.length# MISSOVER;

Please let us know if this answers your question.
Re: SAS formatting programs [message #11104 is a reply to message #11103] Thu, 27 October 2016 11:34 Go to previous messageGo to next message
mwoolf is currently offline  mwoolf
Messages: 13
Registered: March 2016
Member
Hello,
I will work on this and share on the forum so that
others can use this info.
Thank you for the detailed explanation!


Doctor of Public Health student

Certificate in Global Health student

College of Public Health

University of Georgia
SAS formatting programs update [message #11124 is a reply to message #11103] Mon, 31 October 2016 12:03 Go to previous messageGo to next message
mwoolf is currently offline  mwoolf
Messages: 13
Registered: March 2016
Member
Hello,
I realized that I'm getting error messages because
I downloaded the SAS files not ASCII files. Thus,
my log says, "file is in use".

So, if I want to use the SAS files (sas7bdat) I cannot
use this program at all?

Thank you for your assistance thus far.
Re: SAS formatting programs update [message #11630 is a reply to message #11124] Wed, 18 January 2017 07:20 Go to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
The SAS files are appended to the sas7bdat zip files, to serve as a description/map of the data.
Previous Topic: Reading in Niger HH data into SAS Enterprise Guide
Next Topic: Applying correct strata in SAS
Goto Forum:
  


Current Time: Sat Nov 30 23:24:55 Coordinated Universal Time 2024