Help using Base SAS procedures

completetypes+preloadfmt vs completetypes?

Accepted Solution Solved
Reply
Super Contributor
Super Contributor
Posts: 444
Accepted Solution

completetypes+preloadfmt vs completetypes?

Hi all,

These 2 codes below give me the same results.

What actually is preloadfmt here spposed to do?

What difference is supposed to make?

proc summary data=mylib.testo  completetypes chartype ;

class sex/preloadfmt ;

var height weight;

output out=new max=/autoname;

format sex $gender.;proc print;run;

proc format ;

value $gender 'F'='Female'

             'M'='Male'; run;

VS.

proc summary data=mylib.testo  completetypes chartype ;

class sex ;

var height weight;

output out=new max=/autoname;

format sex $gender.;proc print;run;

proc format ;

value $gender 'F'='Female'

             'M'='Male';

             run;


Accepted Solutions
Solution
‎09-16-2013 01:24 PM
Respected Advisor
Posts: 3,799

Re: completetypes+preloadfmt vs completetypes?

You need to create the format before you use it.

PRELOADFMT allows you to use the format to create something from nothing.   As a test add a level to the 'X'='OTHER' and see what happens.

View solution in original post


All Replies
Solution
‎09-16-2013 01:24 PM
Respected Advisor
Posts: 3,799

Re: completetypes+preloadfmt vs completetypes?

You need to create the format before you use it.

PRELOADFMT allows you to use the format to create something from nothing.   As a test add a level to the 'X'='OTHER' and see what happens.

Super Contributor
Super Contributor
Posts: 444

Re: completetypes+preloadfmt vs completetypes?

Posted in reply to data_null__

sorry,what you mean by create the format before you use it?

I already had a  format below my code.

So yes, with preloadfmt "other" appears in my result eventhough 'X' is nowhere in my inputted data but then why worry about "x" or anyhting that is not in my  data?

Super Contributor
Super Contributor
Posts: 444

Re: completetypes+preloadfmt vs completetypes?

Posted in reply to data_null__

oh so you are saying in case we want to show a classification level in the outputs  that is not in the data then we use prleoadfmt?

Super User
Posts: 11,343

Re: completetypes+preloadfmt vs completetypes?

One use, also preloadfmt works in some procedures such as Tabulate that do not have completetypes (actually no types). Completetypes only works in proc means or summary.

Super Contributor
Super Contributor
Posts: 444

Re: completetypes+preloadfmt vs completetypes?

thank you both

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 360 views
  • 3 likes
  • 3 in conversation