## Problem with format table

Solved
Super Contributor
Posts: 261

# Problem with format table

I want to use a formatting table to map months to quarters. I've created a format table below called "quart". I've included a sample dataset with months but I've included two months outside the range of the format table. However, when I use the code check=put(month,quart.); I still get values for the months outside the range of the format table, specifically, 1 for month 13 and 2 for month 21. Is there a way to change the code so that the code is only executed where the months are in the range of the format table. Something like

if check=put(month,quart.) ne "" then do;

Here is the sample code

data quart;
input start \$2. label \$1.;
datalines;
011
021
031
042
052
062
073
083
093
104
114
124
;
run;

data quart;
set quart;
fmtname = "quart";
type = "c";

run;

proc format cntlin = quart fmtlib;
run;

data dataset;
input month \$2.;
datalines;
01
02
13
21
;
run;

data dataset;
set dataset;
check=put(month,quart.);
run;

Accepted Solutions
Solution
‎07-22-2015 04:06 AM
Super User
Posts: 9,599

## Re: Problem with format table

I would suggest putting both sets of data in datasets and use normal merging techniques.  I would also clarify what you mean by "in the range of the format table"?

All Replies
Solution
‎07-22-2015 04:06 AM
Super User
Posts: 9,599

## Re: Problem with format table

I would suggest putting both sets of data in datasets and use normal merging techniques.  I would also clarify what you mean by "in the range of the format table"?

Super Contributor
Posts: 261

## Re: Problem with format table

The field start in the format table quart ranges from 01 to 12 (representing months of the year), the label in the table is the quarter. When I read values from this table in my dataset with "funny" months like 13 and 21, it still returns values.

I would use merges only this is a very simplified example of what I'm doing so merge would appear to be the easier option.

Thanks

🔒 This topic is solved and locked.