NebulousReveal
NebulousReveal

Reputation: 572

Formatting a variable

I have the following format:

value agecf 0 = "35-40" 1 = "41-45" 2 = "46-50" 3 = "51-55" 4 = "56-60";

But then I type the following: format age agecf.; I still get all of the observations (e.g. 35,36,37,.....) instead of the observations grouped into 5 levels. Why?

Upvotes: 1

Views: 101

Answers (1)

cmjohns
cmjohns

Reputation: 4475

You just reversed the left and right sides of the format. The formatted value goes on the right, the original value on the left.

Below is an example with using your format and one which is probably what you were trying to create.

proc format;
value agecf 0 = "35-40" 1 = "41-45" 2 = "46-50" 3 = "51-55" 4 = "56-60";
value newage 35-40="0" 41-45="1" 46-50="2"  51-55="3" 56-60="4";
run;
data test;
input value1;
value2=value1;
format value1 agecf. value2 newage.; 
datalines;
35
45
50
37
46
55
60
;
proc print data=test;run;

Upvotes: 3

Related Questions