Using a data set with a non-existing variable format

Reply
Contributor
Posts: 40

Using a data set with a non-existing variable format

Dear Fellow SAS Users,

I am doing exercises in Base SAS and SAS/STAT (using SAS 9.3 in Windows) from the book "Discovering Statistics Using SAS" by Andy Field and Jeremy Miles, and I encountered the attached strange data set.  It has a non-existing variable format that prevents me from using it.  I would much appreciate your help to fix this problem.

This data set, named downloadfestival.sas7bdat, is in the collection of data provided by the book's companion web site.

The variable GENDER has a format called GENDER, as found when I run PROC CONTENTS.

----------------------------------------------------------------------

        Discovering Statistics Using SAS - Chapter 4 Exercises      34

                     Histogram for Day 1 Hygiene

                                       17:05 Monday, December 31, 2012

                        The CONTENTS Procedure

Data Set Name        CHAPTER4.               Observations          810

                     DOWNLOADFESTIVAL

Member Type          DATA                    Variables             5

Engine               V9                      Indexes               0

Created              Monday, December 31,    Observation Length    40

                     2012 05:54:19 PM

Last Modified        Monday, December 31,    Deleted Observations  0

                     2012 05:54:19 PM

Protection                                   Compressed            NO

Data Set Type                                Sorted                YES

Label

Data Representation  WINDOWS_32

Encoding             wlatin1  Western

                     (Windows)

                  Engine/Host Dependent Information

Data Set Page Size          4096

Number of Data Set Pages    9

First Data Page             1

Max Obs per Page            101

Obs in First Data Page      60

Number of Data Set Repairs  0

Filename                    C:\SAS\SAS Training\Data - Discovering

                            Statistics Using

                            SAS\downloadfestival.sas7bdat

Release Created             9.0301M0

Host Created                W32_7PRO

             Alphabetic List of Variables and Attributes

#  Variable  Type  Len  Format   Label

3  DAY1      Num     8  F8.2     Hygiene (Day 1 of Download Festival)

4  DAY2      Num     8  F8.2     Hygiene (Day 2 of Download Festival)

5  DAY3      Num     8  F8.2     Hygiene (Day 3 of Download Festival)

2  GENDER    Num     8  GENDER.  Gender of Concert Goer

1  TICKNUMB  Num     8  F11.     Ticket Number

                          Sort Information

                        Sortedby       GENDER

                        Validated      YES

                        Character Set  ANSI

When I run the code,

data chapter4.festival;

     set chapter4.downloadfestival;

run;

I get this in the log:

ERROR: The format GENDER was not found or could not be loaded.

I can't even open this data set in the Explorer.  Can anybody fix this problem of a non-existing variable format?

Thank you for your help.

Attachment
Respected Advisor
Posts: 4,934

Re: Using a data set with a non-existing variable format

You can create a copy of the dataset and associate an existing format to variable GENDER :

data test;

set capter4.DownloadFestival;

format gender best10.;

run;

you will see that GENDER takes values 0 and 1. You can then create your own substitute format :

proc format;
value gender
     0 = "M"
     1 = "F";
run;

data test;
set chapter4.DownloadFestival;
format gender gender.;
run;

but you will have to guess which is M and which is F.

PG

PG
Contributor
Posts: 40

Re: Using a data set with a non-existing variable format

Your solution worked, too, PGStats!  Thank you!

Super User
Super User
Posts: 7,076

Re: Using a data set with a non-existing variable format

Set the NOFMTERR option. Or remove the format.

data chapter4.festival;

  set chapter4.downloadfestival;

   format gender ;

run;

Contributor
Posts: 40

Re: Using a data set with a non-existing variable format

That worked, Tom!  Thanks!

Contributor
Posts: 40

Re: Using a data set with a non-existing variable format

Hi Everyone,

I was able to go back to the book and see from the source material that 0 = Male and 1 = Female.  However, assuming that I did not know that, is there any way for me to uncover what the original format GENDER meant?

Thanks,

Eric

Respected Advisor
Posts: 3,156

Re: Using a data set with a non-existing variable format

Not by yourself. You would have to ask the author of the code for the answer. In real life, it should not happen in an environment running SAS on a regular basis, any shipped-out SAS code package should be in the status of "ready to run" with minimum requirement on users, meaning everything needed should be included, such as user manual (interface control document), autoexec.sas, config file, format, auto macro or macro code for compiled macro, etc.

Haikuo

Ask a Question
Discussion stats
  • 6 replies
  • 516 views
  • 7 likes
  • 4 in conversation