If I have a variable that is attached to a format library, how do i reference the formatted value? For example,
if the variable is grade and contains the values like 100, 99, 98, 97...etc. and 90, 91, 92, 93...are As, 80, 81, 82...are Bs and so on. The value of the grade variable is 100, 99, 98...but the formatted values are A, B, C, D...etc. Instead of referencing the original value of grade, which are 100, 99, 98...I want to reference the values A, B, C...which are the values after attaching the variable to the format library. Is there a way of doing this? Or I have to reference 100, 99, 98...?
Referencing in a PROC, such as PROC PRINT, you would associate with a FORMAT statement. If you need to reference the "formatted value" in a DATA step, you need to use a PUT function with the variable and the output format coded as an argument.
Let's figure that your grade format is called GRFMT. So if you want to test the letter value instead of the number, your IF would be something like this:
if put(numgrd,grfmt.) = 'A' then do;
else if put(numgrd,grfmt.) = 'B' then do;
or, you could just make a new variable:
length newvar $1;