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

Hi,

I am trying to use preloadfmt with proc tabulate but I am receiving the following error:

The format for variable SAMPLE_MONTH cannot be preloaded. Preload will have no effect.

Any suggestions?

Thanks

Code example:

proc format;

value time_frame_format (notsorted)

low-<'01JAN2008'd = 'Before 2008'

'01JAN2008'd-<'01JAN2009'd = [worddate20.]

'01JAN2009'd-<'01JAN2010'd = 'Timeframe1'

'01JAN2010'd-high = 'After timeframe1'

;

run;

proc tabulate data=work.data MISSING order=data;

class c_type;

class sample_month / preloadfmt;

var amount;

format sample_month time_frame_format.;

table = c_type, amount * SUM, c_type all='TOTAL';

run;

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

The problem is

'01JAN2008'd-<'01JAN2009'd = [worddate20.]

You will need to expand this, but do you really want all 366 days represented in your summary.

View solution in original post

6 REPLIES 6
data_null__
Jade | Level 19

The problem is

'01JAN2008'd-<'01JAN2009'd = [worddate20.]

You will need to expand this, but do you really want all 366 days represented in your summary.

Brian
Obsidian | Level 7

Thanks greatly appreciated! The sample_month field only contains the first of each month so the summary would be limited to 12 values for that specified range. I now understand that I must expand all the format ranges for preloadfmt to work.

ashlicole
Obsidian | Level 7

Hi, I am having a similar problem. Can you elaborate on what you mean here? The way I'm understanding it, data _null_ is suggesting that the preloadfmt error that brian is receiving is due to the fact that he is using ranges to define his multi-label format. I too am trying to define a multi-label format to use in a proc tabulate and am receiving the error that brian noted.  In my situation, it would be nearly impossible for my to individually define each of my numeric values. However, I see plenty of documented examples (incl on the SAS website) where people are successfully using ranges in their user-defined multilabel format definitions without having to expand out and define each value separately. I think I must be misunderstanding the solution here? Any help would be greatly appreciated! My situation looks something like this (hopefully no typos--i didnt copy/paste here):

proc format; picture testf (multilabel notsorted)

     0-9996="0000" (prefix="2/")

     9997-9999="Worst"

          9997="Worse 1"

          9998="Worse 2";  run;

proc tabulate data=dat1;

class vision /mlf preloadfmt order=data;

class group;

table vision,(group all)*(n colpctn);

format vision testf.; run;

data_null__
Jade | Level 19

Ranges are fine but not they must map to a single value.

0-9996="0000"

Doesn't say make the range 0-9996 a single value.

I've been experimenting with your program in the other thread and it "works" mostly for everything but PRELOADFMT.

ashlicole
Obsidian | Level 7

AHA! This was the jist of my eventual conclusion as well. It seems that this means a picture format will never be able to be preloaded. It makes sense to me that a format could not be preloaded if it is dependent on the data itself (like a picture format is). Unfortunately, the format is useless to me if I can't apply it to this proc tabulate Smiley Sad

data_null__
Jade | Level 19

You may still be able to have your cake and eat it too.  Start a new thread where you explain what you want include sample data and the rest.  Give exact details.

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
  • 6 replies
  • 2780 views
  • 0 likes
  • 3 in conversation