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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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