BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
brophymj
Quartz | Level 8

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;

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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"?

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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"?

brophymj
Quartz | Level 8

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1191 views
  • 0 likes
  • 2 in conversation