Hi, this is my code about proc format and the outcome.
And I got a note:
Your format MAR does not have a $ in the name. Same for EDU. In addition, there is no need to create a whole new data set to assign formats. The entire code you have written can be simplified
filename refile_1 '/home/...';
proc import datafile=refile_1 out=homework dbms=xlsx;
getnames=yes;
run;
proc format;
value edu 1='Illiteracy' 2='Elementary' 3='Junior' 4='Senior High' 5='College' 6='Graduate';
value mar 1='Single' 2='Married' 3='Widowed' 4='Divorced'; /* Please note the use of capital letters in the formatted values */
run;
data homework_3;
set homework;
format edu edu. mar mar.;
label edu='Educational Level' mar='Marital Status'; /* Please note the use of capital letters in the labels */
run;
proc freq data=homework_3;
tables edu mar;
run;
or even simpler, this only requires one data set named HOMEWORK
filename refile_1 '/home/...';
proc import datafile=refile_1 out=homework dbms=xlsx;
getnames=yes;
run;
proc format;
value edu 1='Illiteracy' 2='Elementary' 3='Junior' 4='Senior High' 5='College' 6='Graduate';
value mar 1='Single' 2='Married' 3='Widowed' 4='Divorced'; /* Please note the use of capital letters in the formatted values */
run;
proc datasets library=work nolist;
modify homework;
format mar mar. edu edu.;
label edu='Educational Level' mar='Marital Status'; /* Please note the use of capital letters in the labels */
run;
quit;
proc freq data=homework;
tables edu mar;
run;
In the diary.
And now I use another ways but still not solve the problem.
Thank u.
Your format MAR does not have a $ in the name. Same for EDU. In addition, there is no need to create a whole new data set to assign formats. The entire code you have written can be simplified
filename refile_1 '/home/...';
proc import datafile=refile_1 out=homework dbms=xlsx;
getnames=yes;
run;
proc format;
value edu 1='Illiteracy' 2='Elementary' 3='Junior' 4='Senior High' 5='College' 6='Graduate';
value mar 1='Single' 2='Married' 3='Widowed' 4='Divorced'; /* Please note the use of capital letters in the formatted values */
run;
data homework_3;
set homework;
format edu edu. mar mar.;
label edu='Educational Level' mar='Marital Status'; /* Please note the use of capital letters in the labels */
run;
proc freq data=homework_3;
tables edu mar;
run;
or even simpler, this only requires one data set named HOMEWORK
filename refile_1 '/home/...';
proc import datafile=refile_1 out=homework dbms=xlsx;
getnames=yes;
run;
proc format;
value edu 1='Illiteracy' 2='Elementary' 3='Junior' 4='Senior High' 5='College' 6='Graduate';
value mar 1='Single' 2='Married' 3='Widowed' 4='Divorced'; /* Please note the use of capital letters in the formatted values */
run;
proc datasets library=work nolist;
modify homework;
format mar mar. edu edu.;
label edu='Educational Level' mar='Marital Status'; /* Please note the use of capital letters in the labels */
run;
quit;
proc freq data=homework;
tables edu mar;
run;
Hello, thank you for your response. I followed your advice, but still couldn't achieve the results I expected.
Why weren't the numbers replaced in the form?
Thank u.
@bbibbi_yc wrote:
Hello, thank you for your response. I followed your advice, but still couldn't achieve the results I expected.
Why weren't the numbers replaced in the form?
Because you did not use the formats in the FREQ procedure, as was already mentioned.
Please do not post pictures of code or logs in the future. Always (ALWAYS) copy/paste the text into the appropriate windows (see your "welcome" email when you signed up to the forum). This allows us to quickly annotate and correct your work.
@Kurt_Bremser wrote:
@bbibbi_yc wrote:
Hello, thank you for your response. I followed your advice, but still couldn't achieve the results I expected.
Why weren't the numbers replaced in the form?
Because you did not use the formats in the FREQ procedure, as was already mentioned.
Please do not post pictures of code or logs in the future. Always (ALWAYS) copy/paste the text into the appropriate windows (see your "welcome" email when you signed up to the forum). This allows us to quickly annotate and correct your work.
If the formats are applied at the data set level, proc freq should be using them. Either it's a language incompatibility issue or there's an error in the log somewhere we can't see are my guesses. For language incompatibility, I've seen SAS Studio not work correctly in Chinese keyboard/dialects.
Post the log as well to indicate if something went wrong somewhere.
Also, test this use case which should work.
proc format;
value $ sex_fmt
'F' = 'Female'
'M' = 'Male';
value age_fmt
low - 9 = 'Child'
10-12 = 'Tween'
13-16 = 'Teen'
16 - high = 'Young Adult';
run;
data class;
set sashelp.class;
format age age_fmt. sex $sex_fmt.;
run;
proc freq data=class;
tables age sex;
run;
@bbibbi_yc wrote:
Hello, thank you for your response. I followed your advice, but still couldn't achieve the results I expected.
Why weren't the numbers replaced in the form?
Thank u.
NOTE in the log does not indicate a problem. It is just providing information.
In PROC FREQ, you have to assign the format(s) to the variable(s). You have not done that. I'm sure that your class notes explain how to do that.
Side note: if you are going to assign a format, use proper proper capitalization, proper grammar and so on. For example
value mar 1='Single' ... ;
The reason you use formats is to make something more readable and more meaningful; if you want to make things more readable, use proper capitalization and grammar.
Hi bbibi:
A few SAS procedures do not generate any reports by themselves, proc sort and proc format among them. The only way you'll know they've compiled is via a note in your log.
rich
Hello, that means I can't see the 'Single' or other else in my table?
It sounds like a stupid question, but I really don't understand. Thank you for your patient response.
@bbibbi_yc wrote:
Hello, that means I can't see the 'Single' or other else in my table?
It sounds like a stupid question, but I really don't understand. Thank you for your patient response.
Formats impact how the value is DISPLAYED, not the value that is STORED.
So if you have a format that display the number 1 as the string Single then the number 1 is what is stored in the dataset. If the format is being used when you "look" at the data then you will see Single but the value in the dataset is still the number 1.
So in the tabular report (what I normally mean when I use the word TABLE) produced by PROC FREQ the formatted value is displayed. So if the variable has a format attached that converts 1 to Single then Single will show up in the report. If there is no format attached to a number than SAS will normally display it using the BEST12. format.
/*import data*/
Filename refile_1 '/home/u63518324/sasuser.v94/Epi_test.xls';
proc import datafile=refile_1
out=homework
dbms=xls;
getnames=yes;
run;
/*change label, format*/
proc format;
value edu 1='Illiteracy' 2='Elementary' 3='Junior' 4='Senior High' 5='College' 6='Graduate';
value mar 1='Single' 2='Married' 3='Widowed' 4='Divorced';
run;
data homework_3;
set homework;
format edu edu. mar mar.;
label edu='Educational Level' mar='Marital Status';
run;
options nofmterr;
proc freq data=homework_3;
tables edu mar;
run;
Hello, this is my code. I'm wondering where the problem is that prevents me from opening my data display results. Also, the following error still appears in the log.
85 format edu edu. mar mar.;
____
484
NOTE 484-185: Format $EDU was not found or could not be loaded.
85 ! format edu edu. mar mar.;
____
484
NOTE 484-185: Format $MAR was not found or could not be loaded.
Thank u so much.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.