I have created a formats like following
data formatset;
input fmtname $ start $ end $ label $;
datalines;
$test region1 region3 zone1
$test region4 region5 zone2
$test region6 region7 zone3
;
run;
proc format library = work.formats
cntlin = work.formatset;
run;
quit;
Problem: I will have new datalines data with the variable region
. And i want to have a new attribute zone
which use the format $test.
data output;
input region $;
format zone $test.;
zone = region;
datalines;
region1
region2
region3
region4
region5
region6
region7
region8
;
run;
You need to specify a width when using your format to make sure that enough of the characters are read from your zone
variable. Try format zone $test7.;
in your second data step.
If you don't specify a width, SAS defaults to the maximum length of any of the displayed values defined for the format. It will then read only that many characters (in your case 5) from the formatted variable when looking for formatted values to display, and if there isn't a value specified in the format for those 5 characters then they are displayed verbatim.