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;
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"?
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"?
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.