BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tianerhu
Pyrite | Level 9
LIBNAME PUF "C:\SAS data and program\data\data for project in SAS class";
OPTIONS FMTSEARCH = (PUF WORK SASUSER);

%LET MYPATH = C:\SAS data and program\data\data for project in SAS class;
DATA MYPROJECT;
SET PUF.NISTEENPUF18(KEEP = SEQNUMT PDAT2 PROVWT_C STRATUM YEAR AGE SEX RACEETHK EDUC1 AGEGRP_M_I MARITAL2 INCPORAR_I INS_STAT2_I CKUP_11_12 CEN_REG FACILITY STATE P_UTDHPV P_UTDHPV2 P_UTDHPV_15INT P_UTDMEN P_UTDMENACWY P_UTDTD P_UTDTDAP P_UTDTDAP7);

/*** ASSIGNING NEW AGE OF TEEN VARIABLE:  1 = 13 YEARS, 2 = 14 YEARS, 3 = 15 YEARS, 4 = 16 YEARS, AND 5 = 17 YEARS ***/
	NEWAGE = .;
	IF AGE IN (13) THEN NEWAGE = 1;
	ELSE IF AGE IN (14) THEN NEWAGE = 2;
	ELSE IF AGE IN (15) THEN NEWAGE = 3;
	ELSE IF AGE IN (16) THEN NEWAGE = 4;
	ELSE IF AGE IN (17) THEN NEWAGE = 5;

/*	NEWAGE2 = AGE - 12;*/

/*** ASSIGNING AGE GROUP OF TEEN VARIABLE:  1 = (13 - 15)YEARS; 2 = (16-17) YEARS. ***/
	TEENAGEGP = .;
	IF AGE IN (13, 14, 15) THEN TEENAGEGP = 1;
	ELSE IF AGE IN (16, 17) THEN TEENAGEGP = 2;

/*** REGROUPING 11-12 YEAR OLD WELL-CHILD EXAM OR CHECK-UP OF TEEN: BY COMBINING DON'T KNOW /REFUSED / MISSING AS 3 ***/
	MYCKUP1112 = CKUP_11_12;
	IF  CKUP_11_12 IN (., 77, 99) THEN MYCKUP1112 = 3;

/*** ASSIGNING MISSING FACILITY AS UNKNOW = 6 ***/
	MYFACILITY = FACILITY;
	IF  FACILITY IN (.) THEN MYFACILITY = 6;

/*** INCOME TO POVERTY RATIO VARIABLE 1= <133%; 2=133% TO 322% ***/
	IF 0 <= INCPORAR_I < 1.33162 THEN MYINCTOPOV = 1;
	ELSE IF 1.33162 <= INCPORAR_I < 3.22046 THEN MYINCTOPOV = 2;

/*** REASSIGNING RACE/ETHNICITY VARIABLES: 1 = NH-WHITES; 2 = NH-BLACKS; 3 = HISPANICS; 4 = NH-OTHERS ***/
	MYRACEETH = .;
	IF RACEETHK = 1 THEN MYRACEETH = 3;
	ELSE IF RACEETHK = 2 THEN MYRACEETH = 1;
	ELSE IF RACEETHK = 3 THEN MYRACEETH = 2;
	ELSE IF RACEETHK = 4 THEN MYRACEETH = 4;

RUN;

/***************************************************************************/
/*** THIS PROGRAM PRODUCES ALL MY VARIABLE CREATED IN THE SUBSET DATA  ***/
/***************************************************************************/

PROC CONTENTS DATA = MYPROJECT VARNUM;
RUN;


log :

50 LIBNAME PUF "C:\SAS data and program\data\data for project in SAS class";
NOTE: Libref PUF was successfully assigned as follows:
Engine: V9
Physical Name: C:\SAS data and program\data\data for project in SAS class
51 OPTIONS FMTSEARCH = (PUF WORK SASUSER);
52
53 %LET MYPATH = C:\SAS data and program\data\data for project in SAS class;
54 DATA MYPROJECT;
55 SET PUF.NISTEENPUF18(KEEP = SEQNUMT PDAT2 PROVWT_C STRATUM YEAR AGE SEX RACEETHK EDUC1 AGEGRP_M_I
55 ! MARITAL2 INCPORAR_I INS_STAT2_I CKUP_11_12 CEN_REG FACILITY STATE P_UTDHPV P_UTDHPV2
55 ! P_UTDHPV_15INT P_UTDMEN P_UTDMENACWY P_UTDTD P_UTDTDAP P_UTDTDAP7);
56
57 /*** ASSIGNING NEW AGE OF TEEN VARIABLE: 1 = 13 YEARS, 2 = 14 YEARS, 3 = 15 YEARS, 4 = 16 YEARS,
57 ! AND 5 = 17 YEARS ***/
58 NEWAGE = .;
59 IF AGE IN (13) THEN NEWAGE = 1;
60 ELSE IF AGE IN (14) THEN NEWAGE = 2;
61 ELSE IF AGE IN (15) THEN NEWAGE = 3;
62 ELSE IF AGE IN (16) THEN NEWAGE = 4;
63 ELSE IF AGE IN (17) THEN NEWAGE = 5;
64
65 /* NEWAGE2 = AGE - 12;*/
66
67 /*** ASSIGNING AGE GROUP OF TEEN VARIABLE: 1 = (13 - 15)YEARS; 2 = (16-17) YEARS. ***/
68 TEENAGEGP = .;
69 IF AGE IN (13, 14, 15) THEN TEENAGEGP = 1;
70 ELSE IF AGE IN (16, 17) THEN TEENAGEGP = 2;
71
72 /*** REGROUPING 11-12 YEAR OLD WELL-CHILD EXAM OR CHECK-UP OF TEEN: BY COMBINING DON'T KNOW
72 ! /REFUSED / MISSING AS 3 ***/
73 MYCKUP1112 = CKUP_11_12;
74 IF CKUP_11_12 IN (., 77, 99) THEN MYCKUP1112 = 3;
75
76 /*** ASSIGNING MISSING FACILITY AS UNKNOW = 6 ***/
77 MYFACILITY = FACILITY;
78 IF FACILITY IN (.) THEN MYFACILITY = 6;
79
80 /*** INCOME TO POVERTY RATIO VARIABLE 1= <133%; 2=133% TO 322% ***/
81 IF 0 <= INCPORAR_I < 1.33162 THEN MYINCTOPOV = 1;
82 ELSE IF 1.33162 <= INCPORAR_I < 3.22046 THEN MYINCTOPOV = 2;
83
84 /*** REASSIGNING RACE/ETHNICITY VARIABLES: 1 = NH-WHITES; 2 = NH-BLACKS; 3 = HISPANICS; 4 =
84 ! NH-OTHERS ***/
85 MYRACEETH = .;
86 IF RACEETHK = 1 THEN MYRACEETH = 3;
87 ELSE IF RACEETHK = 2 THEN MYRACEETH = 1;
88 ELSE IF RACEETHK = 3 THEN MYRACEETH = 2;
89 ELSE IF RACEETHK = 4 THEN MYRACEETH = 4;
90
91 RUN;

ERROR: The format $CHARGEN was not found or could not be loaded.
ERROR: The format ADEQ was not found or could not be loaded.
ERROR: The format NUMGEN was not found or could not be loaded.
ERROR: The format NUMGEN was not found or could not be loaded.
ERROR: The format NUMGEN was not found or could not be loaded.
ERROR: The format YNDKRF was not found or could not be loaded.
ERROR: The format NUMDKRF was not found or could not be loaded.
ERROR: The format AGEGRP_M was not found or could not be loaded.
ERROR: The format CENREG was not found or could not be loaded.
ERROR: The format EDUC4_M was not found or could not be loaded.
ERROR: The format NUMGEN was not found or could not be loaded.
ERROR: The format MAR_PUF2_ was not found or could not be loaded.
ERROR: The format RACEETHK was not found or could not be loaded.
ERROR: The format SEX was not found or could not be loaded.
ERROR: The format STATE was not found or could not be loaded.
ERROR: The format FACILSUM was not found or could not be loaded.
ERROR: The format UTD was not found or could not be loaded.
ERROR: The format UTD was not found or could not be loaded.
ERROR: The format UTD was not found or could not be loaded.
ERROR: The format UTD was not found or could not be loaded.
ERROR: The format UTD was not found or could not be loaded.
ERROR: The format UTD was not found or could not be loaded.
ERROR: The format UTD was not found or could not be loaded.
ERROR: The format UTD was not found or could not be loaded.
ERROR: The format INS_STAT2_I was not found or could not be loaded.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.MYPROJECT may be incomplete. When this step was stopped there were 0
observations and 31 variables.
WARNING: Data set WORK.MYPROJECT was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.17 seconds
cpu time 0.17 seconds


92
93 /***************************************************************************/
94 /*** THIS PROGRAM PRODUCES ALL MY VARIABLE CREATED IN THE SUBSET DATA ***/
95 /***************************************************************************/
96
97 PROC CONTENTS DATA = MYPROJECT VARNUM;
98 RUN;

NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds

please tell me what's  wrong with the code ? thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Add this line to the top of your program.

options nofmterr;

That will convert the ERROR messages into note/warnings so that you can actually create the dataset and work with it.

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

These are custom formats. You need to have the code for these formats prior to the usage of the format in the program, or in a FMTLIB that your program accesses. You can turn off the error messages with

 

options nofmterr;

but then of course you can't use the custom formats and things may not run as expected. Whoever created these data sets knows where the custom formats are located and can provide you with instructions on how to use them.

 

@tianerhu you have been in this forum long enough to know that LOG must be in a "Insert Code" box accessed by clicking on the </> icon. Please don't provide us with unformatted log any more.

--
Paige Miller
tianerhu
Pyrite | Level 9
Thank you for your help .
Sorry about that .
I will do what you say next time.
Tom
Super User Tom
Super User

So you told SAS to look for formats in the catalog PUF.FORMATS.

OPTIONS FMTSEARCH = (PUF WORK SASUSER);

Does that catalog exist?  What does it have in it?  Ask PROC FORMAT to show you.

proc format lib=puf.formats noprint out=formats; run;
proc freq data=formats;
  tables fmtname;
run;
tianerhu
Pyrite | Level 9
99   proc format lib=puf.formats noprint out=formats;
99 !                                                  run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

ERROR: Catalog PUF.FORMATS does not exist.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.FORMATS may be incomplete.  When this step was stopped there were 0
         observations and 0 variables.


100  proc freq data=formats;
101    tables fmtname;
ERROR: Variable FMTNAME not found.
102  run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE FREQ used (Total process time):
      real time           0.11 seconds
      cpu time            0.03 second

yes , the pub.format is not exist . actually , this code is provided by my teacher teching SAS.

 

Tom
Super User Tom
Super User

Then look for another piece of code from your teacher that includes the PROC FORMAT statement(s) to define the formats and run that first so that the formats exist before you create the dataset that is trying to reference them.

tianerhu
Pyrite | Level 9

if i cannot find the format file , what should I do ?

Tom
Super User Tom
Super User

Add this line to the top of your program.

options nofmterr;

That will convert the ERROR messages into note/warnings so that you can actually create the dataset and work with it.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 3007 views
  • 1 like
  • 3 in conversation