Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dyamic proc format

Status
Not open for further replies.

saspgmr

Programmer
Feb 16, 2007
4
US
Has any body used dynamic proc format? I have used it long time back and trying to recollect it.It basically has key words like start ,label, fmtname etc.Could any body help me on this.

Thanks,
Zaheer
 
Sure I use it all the time. I wrote a macro to generate the format.
First you need a dataset that is set up for the 'cntlin' option on the Proc Format to be used. (This is what my macro does.)

Code:
%macro fmt_setup(fds_nm  = ,
                 out_nm  = ,
                 fm_name = ,
                 f_label = ,
                 f_type  = ,
                 f_value = );

   *** SET THE DATA SET FOR THE PROC FORMAT STEP   ***;
   data &out_nm(keep=label start type fmtname );
     set &fds_nm  end = last;
     length
       label   $40
       start   $40
       type    $4
       fmtname $10
       ;
   
       label   = "&f_label";
       start   = &f_value;
       type    = "&f_type";
       fmtname = "&fm_name";

   
       if last then do;
         output;
         label   = 'NO';
         start   = 'other';
         type    = "&f_type";
         fmtname = "&fm_name";
         output;
       end;
       else
        output;
   run;

   proc format 
     cntlin = &out_nm;
   run;

   quit; *** USED FOR FORMAT ERROR ***;
%mend fmt_setup;

Please note that this code is for numeric value substitution and not character formats. But you can figure out how to modify the code to suit your needs should you need this for character formats too.

Klaz
 
Thank you so much Klaz,
Its really helpful and wonderful.
You have been doing a great job for the Forum.

I appreciate your solutions.

Thanks,
Zaheer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top