There is no need to list all Names to make the format. We can create format using the data set. I show how it can be made. Your interest is not known as how you will be using the crime rates. If it is known, an approprite solution can be given. Besides the Format, Hash Objects and Array with PIBw. can be used. data have;
input state &$15.;
datalines;
Kentucky
Louisiana
Maine
Maryland
Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Nevada
New Hampshire
New Jersey
New Mexico
New York
North Carolina
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina
;
run;
data cnt;
retain fmtname 's2num' type 'I';
set have end = last;
start = state;
label = _N_;
output;
if last then do;
hlo = 'O';
label = 0;
output;
end;
run;
proc sort data = cnt nodupkey;
by start;
run;
proc format cntlin = cnt;
run;
We can verify the Format by cycling the original data set. Note the use of INPUT(STATE, s2num.) to get the unique number for a given State.
data want;
set have;
state_id = input(state, s2num.);
run;
... View more