BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
xoxozav_1
Calcite | Level 5

I'm trying to create a defined format for the values of the variable HV201,
but I'm not seeing the updated format in the proc freq and print tables of the variable HV201.
I tried to change the name of the variable in the proc format step to the value HV201fmt,
but it did not work. Could you please tell me if I am doing something wrong?

Thank you for your help

This is the SAS code :

libname Assig2 "/folders/myfolders/study3";
data work.homework2;
set Assig2.homework2;
run;
proc format;
value HV201fmt
11="Piped into dwelling"
12= "Piped to yard/plot"
13= "Public tap/standpipe"
21= "Tube well or borehole"
31= "Protected well"
32= "Unprotected well"
41="Protected spring"
42= "Unprotected spring"
43= "River/dam/lake/ponds/stream/canal/irrigation channel"
51= "Rainwater"
61= "Tanker truck"
71= "Bottled water or sachet"
96= "Other"
99= "Missing";
run;
proc print data=work.homework2 (obs=10);
format HV201  HV201A. ;
run;
proc freq data=work.homework2;
format HV201  HV201A. ;
run;



Log:

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 libname Assig2 "/folders/myfolders/study3";
NOTE: Libref ASSIG2 was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/study3
74 data work.homework2;
75 set Assig2.homework2;
NOTE: Data file ASSIG2.HOMEWORK2.DATA is in a format that is native to another host, or the file encoding does not match the
session encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce
performance.
76 run;
 
NOTE: Format HV003A was not found or could not be loaded.
NOTE: Format HV025A was not found or could not be loaded.
NOTE: Format HV106A was not found or could not be loaded.
NOTE: Format HV108A was not found or could not be loaded.
NOTE: Format HV201A was not found or could not be loaded.
NOTE: Format HV204A was not found or could not be loaded.
NOTE: Format HV205A was not found or could not be loaded.
NOTE: Format HV206A was not found or could not be loaded.
NOTE: Format HV213A was not found or could not be loaded.
NOTE: Format HV214A was not found or could not be loaded.
NOTE: Format HV215A was not found or could not be loaded.
NOTE: Format HV219A was not found or could not be loaded.
NOTE: Format HV220A was not found or could not be loaded.
NOTE: Format HV243AA was not found or could not be loaded.
NOTE: There were 3832 observations read from the data set ASSIG2.HOMEWORK2.
NOTE: The data set WORK.HOMEWORK2 has 3832 observations and 20 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
 
 
77 proc format;
78 value HV201fmt
79 11="Piped into dwelling"
80 12= "Piped to yard/plot"
81 13= "Public tap/standpipe"
82 21= "Tube well or borehole"
83 31= "Protected well"
84 32= "Unprotected well"
85 41="Protected spring"
86 42= "Unprotected spring"
87 43= "River/dam/lake/ponds/stream/canal/irrigation channel"
88 51= "Rainwater"
89 61= "Tanker truck"
90 71= "Bottled water or sachet"
91 96= "Other"
92 99= "Missing";
NOTE: Format HV201FMT is already on the library WORK.FORMATS.
NOTE: Format HV201FMT has been output.
93 run;
 
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
94 proc print data=work.homework2 (obs=10);
95 format HV201 HV201A. ;
96 run;
 
NOTE: There were 10 observations read from the data set WORK.HOMEWORK2.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.06 seconds
cpu time 0.06 seconds
 
 
97 proc freq data=work.homework2;
98 format HV201 HV201A. ;
99 run;
 
NOTE: There were 3832 observations read from the data set WORK.HOMEWORK2.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.89 seconds
cpu time 0.90 seconds
 
 
100
101 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
113
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Your format name is HV201fmt, not HV201A as in your code. 

 

So this line of code is incorrect because you don't have a format with that name.

format HV201  HV201A. ;

 

Try:

 

format HV201  HV201fmt. ;
Spoiler

@xoxozav_1 wrote:

I'm trying to create a defined format for the values of the variable HV201,
but I'm not seeing the updated format in the proc freq and print tables of the variable HV201.
I tried to change the name of the variable in the proc format step to the value HV201fmt,
but it did not work. Could you please tell me if I am doing something wrong?

Thank you for your help

This is the SAS code :

libname Assig2 "/folders/myfolders/study3";
data work.homework2;
set Assig2.homework2;
run;
proc format;
value HV201fmt
11="Piped into dwelling"
12= "Piped to yard/plot"
13= "Public tap/standpipe"
21= "Tube well or borehole"
31= "Protected well"
32= "Unprotected well"
41="Protected spring"
42= "Unprotected spring"
43= "River/dam/lake/ponds/stream/canal/irrigation channel"
51= "Rainwater"
61= "Tanker truck"
71= "Bottled water or sachet"
96= "Other"
99= "Missing";
run;
proc print data=work.homework2 (obs=10);
format HV201  HV201A. ;
run;
proc freq data=work.homework2;
format HV201  HV201A. ;
run;



Log:

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 libname Assig2 "/folders/myfolders/study3";
NOTE: Libref ASSIG2 was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/study3
74 data work.homework2;
75 set Assig2.homework2;
NOTE: Data file ASSIG2.HOMEWORK2.DATA is in a format that is native to another host, or the file encoding does not match the
session encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce
performance.
76 run;
 
NOTE: Format HV003A was not found or could not be loaded.
NOTE: Format HV025A was not found or could not be loaded.
NOTE: Format HV106A was not found or could not be loaded.
NOTE: Format HV108A was not found or could not be loaded.
NOTE: Format HV201A was not found or could not be loaded.
NOTE: Format HV204A was not found or could not be loaded.
NOTE: Format HV205A was not found or could not be loaded.
NOTE: Format HV206A was not found or could not be loaded.
NOTE: Format HV213A was not found or could not be loaded.
NOTE: Format HV214A was not found or could not be loaded.
NOTE: Format HV215A was not found or could not be loaded.
NOTE: Format HV219A was not found or could not be loaded.
NOTE: Format HV220A was not found or could not be loaded.
NOTE: Format HV243AA was not found or could not be loaded.
NOTE: There were 3832 observations read from the data set ASSIG2.HOMEWORK2.
NOTE: The data set WORK.HOMEWORK2 has 3832 observations and 20 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
 
 
77 proc format;
78 value HV201fmt
79 11="Piped into dwelling"
80 12= "Piped to yard/plot"
81 13= "Public tap/standpipe"
82 21= "Tube well or borehole"
83 31= "Protected well"
84 32= "Unprotected well"
85 41="Protected spring"
86 42= "Unprotected spring"
87 43= "River/dam/lake/ponds/stream/canal/irrigation channel"
88 51= "Rainwater"
89 61= "Tanker truck"
90 71= "Bottled water or sachet"
91 96= "Other"
92 99= "Missing";
NOTE: Format HV201FMT is already on the library WORK.FORMATS.
NOTE: Format HV201FMT has been output.
93 run;
 
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
94 proc print data=work.homework2 (obs=10);
95 format HV201 HV201A. ;
96 run;
 
NOTE: There were 10 observations read from the data set WORK.HOMEWORK2.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.06 seconds
cpu time 0.06 seconds
 
 
97 proc freq data=work.homework2;
98 format HV201 HV201A. ;
99 run;
 
NOTE: There were 3832 observations read from the data set WORK.HOMEWORK2.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.89 seconds
cpu time 0.90 seconds
 
 
100
101 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
113
 

 


View solution in original post

2 REPLIES 2
Reeza
Super User

Your format name is HV201fmt, not HV201A as in your code. 

 

So this line of code is incorrect because you don't have a format with that name.

format HV201  HV201A. ;

 

Try:

 

format HV201  HV201fmt. ;
Spoiler

@xoxozav_1 wrote:

I'm trying to create a defined format for the values of the variable HV201,
but I'm not seeing the updated format in the proc freq and print tables of the variable HV201.
I tried to change the name of the variable in the proc format step to the value HV201fmt,
but it did not work. Could you please tell me if I am doing something wrong?

Thank you for your help

This is the SAS code :

libname Assig2 "/folders/myfolders/study3";
data work.homework2;
set Assig2.homework2;
run;
proc format;
value HV201fmt
11="Piped into dwelling"
12= "Piped to yard/plot"
13= "Public tap/standpipe"
21= "Tube well or borehole"
31= "Protected well"
32= "Unprotected well"
41="Protected spring"
42= "Unprotected spring"
43= "River/dam/lake/ponds/stream/canal/irrigation channel"
51= "Rainwater"
61= "Tanker truck"
71= "Bottled water or sachet"
96= "Other"
99= "Missing";
run;
proc print data=work.homework2 (obs=10);
format HV201  HV201A. ;
run;
proc freq data=work.homework2;
format HV201  HV201A. ;
run;



Log:

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 libname Assig2 "/folders/myfolders/study3";
NOTE: Libref ASSIG2 was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/study3
74 data work.homework2;
75 set Assig2.homework2;
NOTE: Data file ASSIG2.HOMEWORK2.DATA is in a format that is native to another host, or the file encoding does not match the
session encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce
performance.
76 run;
 
NOTE: Format HV003A was not found or could not be loaded.
NOTE: Format HV025A was not found or could not be loaded.
NOTE: Format HV106A was not found or could not be loaded.
NOTE: Format HV108A was not found or could not be loaded.
NOTE: Format HV201A was not found or could not be loaded.
NOTE: Format HV204A was not found or could not be loaded.
NOTE: Format HV205A was not found or could not be loaded.
NOTE: Format HV206A was not found or could not be loaded.
NOTE: Format HV213A was not found or could not be loaded.
NOTE: Format HV214A was not found or could not be loaded.
NOTE: Format HV215A was not found or could not be loaded.
NOTE: Format HV219A was not found or could not be loaded.
NOTE: Format HV220A was not found or could not be loaded.
NOTE: Format HV243AA was not found or could not be loaded.
NOTE: There were 3832 observations read from the data set ASSIG2.HOMEWORK2.
NOTE: The data set WORK.HOMEWORK2 has 3832 observations and 20 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
 
 
77 proc format;
78 value HV201fmt
79 11="Piped into dwelling"
80 12= "Piped to yard/plot"
81 13= "Public tap/standpipe"
82 21= "Tube well or borehole"
83 31= "Protected well"
84 32= "Unprotected well"
85 41="Protected spring"
86 42= "Unprotected spring"
87 43= "River/dam/lake/ponds/stream/canal/irrigation channel"
88 51= "Rainwater"
89 61= "Tanker truck"
90 71= "Bottled water or sachet"
91 96= "Other"
92 99= "Missing";
NOTE: Format HV201FMT is already on the library WORK.FORMATS.
NOTE: Format HV201FMT has been output.
93 run;
 
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
94 proc print data=work.homework2 (obs=10);
95 format HV201 HV201A. ;
96 run;
 
NOTE: There were 10 observations read from the data set WORK.HOMEWORK2.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.06 seconds
cpu time 0.06 seconds
 
 
97 proc freq data=work.homework2;
98 format HV201 HV201A. ;
99 run;
 
NOTE: There were 3832 observations read from the data set WORK.HOMEWORK2.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.89 seconds
cpu time 0.90 seconds
 
 
100
101 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
113
 

 


xoxozav_1
Calcite | Level 5
Reeza:
I have fixed it. Thank you very much for your help.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 362 views
  • 1 like
  • 2 in conversation