I am trying to format a variable range. I know I am missing something. Not sure how to input into SAS.
libname hw4 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Assignment 4'; proc format; value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers'; value txfmt 1 = "treatment" 0 = "Placebo"; run; proc format; value $bmifmt -HIGH bmi> 25 = "overweight" LOW-0<bmi<= 25 = "normal"; run;
ERROR: Unable to clear or re-assign the library HW4 because it is still in use. ERROR: Error in the LIBNAME statement. 26 proc format; 27 value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers'; NOTE: Format CSFMT is already on the library WORK.FORMATS. NOTE: Format CSFMT has been output. 28 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 29 proc format; 30 value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers'; NOTE: Format CSFMT is already on the library WORK.FORMATS. NOTE: Format CSFMT has been output. 31 value txfmt 1 = "treatment" 0 = "Placebo"; NOTE: Format TXFMT has been output. 32 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 33 value $bmifmt bmi >25 = "overweight" 0<bmi<= 25 = "normal"; ----- 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 34 run; 35 value $bmifmt HIGH bmi> 25 = "overweight" 0<bmi<= 25 = "normal"; ----- 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 36 run; 37 proc format; 38 value $bmifmt HIGH bmi> 25 = "overweight" 0<bmi<= 25 = "normal"; ---- --- 22 76 202 ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant, a missing value, ;, (, LOW, OTHER. ERROR 76-322: Syntax error, statement will be ignored. ERROR 202-322: The option or parameter is not recognized and will be ignored. 38 ! value $bmifmt HIGH bmi> 25 = "overweight" 0<bmi<= 25 = "normal"; --- 22 NOTE: 25 is a numeric field and a character format is defined. ERROR 22-322: Syntax error, expecting one of the following: (, ',', -, =. NOTE: The previous statement has been deleted. 39 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds NOTE: The SAS System stopped processing this step because of errors. 40 proc format; 41 value $bmifmt -HIGH bmi> 25 = "overweight" LOW-0<bmi<= 25 = "normal"; - - 22 200 200 ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant, a missing value, ;, (, LOW, OTHER. ERROR 200-322: The symbol is not recognized and will be ignored. 41 ! value $bmifmt -HIGH bmi> 25 = "overweight" LOW-0<bmi<= 25 = "normal"; - 22 NOTE: 25 is a numeric field and a character format is defined. ERROR: This range is repeated, or values overlap: 25-25. ERROR 22-322: Syntax error, expecting one of the following: (, ',', =. NOTE: The previous statement has been deleted. 42 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.00 seconds cpu time 0.01 seconds NOTE: The SAS System stopped processing this step because of errors. 43 proc format; 44 value $bmifmt -HIGH bmi> 25 = "overweight" LOW-0<bmi<= 25 = "normal"; - - 22 200 200 ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant, a missing value, ;, (, LOW, OTHER. ERROR 200-322: The symbol is not recognized and will be ignored. 44 ! value $bmifmt -HIGH bmi> 25 = "overweight" LOW-0<bmi<= 25 = "normal"; - 22 NOTE: 25 is a numeric field and a character format is defined. ERROR: This range is repeated, or values overlap: 25-25. ERROR 22-322: Syntax error, expecting one of the following: (, ',', =. NOTE: The previous statement has been deleted. 45 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds NOTE: The SAS System stopped processing this step because of errors.
Your BMI format does look weird to me.
proc format;
value $bmifmt -HIGH bmi> 25 = "overweight" LOW-0<bmi<= 25 = "normal";
run;
Did you perhaps mean:
proc format;
value bmifmt
LOW - 25 = "normal"
25 - High = "overweight";
run;
@MisterJenn wrote:
I am trying to format a variable range. I know I am missing something. Not sure how to input into SAS.
libname hw4 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Assignment 4'; proc format; value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers'; value txfmt 1 = "treatment" 0 = "Placebo"; run; proc format; value $bmifmt -HIGH bmi> 25 = "overweight" LOW-0<bmi<= 25 = "normal"; run;ERROR: Unable to clear or re-assign the library HW4 because it is still in use. ERROR: Error in the LIBNAME statement. 26 proc format; 27 value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers'; NOTE: Format CSFMT is already on the library WORK.FORMATS. NOTE: Format CSFMT has been output. 28 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 29 proc format; 30 value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers'; NOTE: Format CSFMT is already on the library WORK.FORMATS. NOTE: Format CSFMT has been output. 31 value txfmt 1 = "treatment" 0 = "Placebo"; NOTE: Format TXFMT has been output. 32 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 33 value $bmifmt bmi >25 = "overweight" 0<bmi<= 25 = "normal"; ----- 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 34 run; 35 value $bmifmt HIGH bmi> 25 = "overweight" 0<bmi<= 25 = "normal"; ----- 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 36 run; 37 proc format; 38 value $bmifmt HIGH bmi> 25 = "overweight" 0<bmi<= 25 = "normal"; ---- --- 22 76 202 ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant, a missing value, ;, (, LOW, OTHER. ERROR 76-322: Syntax error, statement will be ignored. ERROR 202-322: The option or parameter is not recognized and will be ignored. 38 ! value $bmifmt HIGH bmi> 25 = "overweight" 0<bmi<= 25 = "normal"; --- 22 NOTE: 25 is a numeric field and a character format is defined. ERROR 22-322: Syntax error, expecting one of the following: (, ',', -, =. NOTE: The previous statement has been deleted. 39 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds NOTE: The SAS System stopped processing this step because of errors. 40 proc format; 41 value $bmifmt -HIGH bmi> 25 = "overweight" LOW-0<bmi<= 25 = "normal"; - - 22 200 200 ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant, a missing value, ;, (, LOW, OTHER. ERROR 200-322: The symbol is not recognized and will be ignored. 41 ! value $bmifmt -HIGH bmi> 25 = "overweight" LOW-0<bmi<= 25 = "normal"; - 22 NOTE: 25 is a numeric field and a character format is defined. ERROR: This range is repeated, or values overlap: 25-25. ERROR 22-322: Syntax error, expecting one of the following: (, ',', =. NOTE: The previous statement has been deleted. 42 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.00 seconds cpu time 0.01 seconds NOTE: The SAS System stopped processing this step because of errors. 43 proc format; 44 value $bmifmt -HIGH bmi> 25 = "overweight" LOW-0<bmi<= 25 = "normal"; - - 22 200 200 ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant, a missing value, ;, (, LOW, OTHER. ERROR 200-322: The symbol is not recognized and will be ignored. 44 ! value $bmifmt -HIGH bmi> 25 = "overweight" LOW-0<bmi<= 25 = "normal"; - 22 NOTE: 25 is a numeric field and a character format is defined. ERROR: This range is repeated, or values overlap: 25-25. ERROR 22-322: Syntax error, expecting one of the following: (, ',', =. NOTE: The previous statement has been deleted. 45 run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds NOTE: The SAS System stopped processing this step because of errors.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.