The SAS Output Delivery System and reporting techniques

Reg. Macro in Proc Format

Reply
N/A
Posts: 0

Reg. Macro in Proc Format

Hi,

I have to format some specific, conditions. So, I like to invoke macro in between the format area.

Examaple:

If I start the proc format;

value $polrule

'0000' = 'none'
'0001' = 'Customer Age Range'
'0037' = 'Military service not completed'
'0058' = 'Employee'
'0097' = 'Five year finance low deposit'
'0132' = 'Employment Type'
'0141' = 'Self Employed'

is common to all the countries.

but is some coding is common to but with different abbreviation.
For India:
'0002' = 'Customer minimum age'
'0009' = 'Vehicle age and term'
'0013' = 'Unavailable'
'0029' = 'Advance > E35000'
For Pakistan:
'0002' = 'Customer Age < 18 or > 70'
'0009' = 'Vehicle Age + Term > 6 years'
'0013' = 'Incomplete bureau search'

Like this When i call the India that macro which is invoke that corresponding india or pakistan like..

Thanks in advance.
Super Contributor
Posts: 260

Re: Reg. Macro in Proc Format

Maybe you can try to re-use your own format into new ones, something like...

OPTION FMTSEARCH = (SASUSER WORK) ;
PROC FORMAT LIB = SASUSER ;
VALUE $comrule
'0000' = 'none'
'0001' = 'Customer Age Range'
'0037' = 'Military service not completed'
'0058' = 'Employee'
'0097' = 'Five year finance low deposit'
'0132' = 'Employment Type'
'0141' = 'Self Employed'
;
VALUE $india
'0002' = 'Customer minimum age'
'0009' = 'Vehicle age and term'
'0013' = 'Unavailable'
'0029' = 'Advance > E35000'
OTHER = [$comrule.]
;
VALUE $pakis
'0002' = 'Customer Age < 18 or > 70'
'0009' = 'Vehicle Age + Term > 6 years'
'0013' = 'Incomplete bureau search'
OTHER = [$comrule.]
;
RUN ;

Then, you just have to specify which format ($india. or $pakis.) is to be used in the rest of your programs.
N/A
Posts: 0

Re: Reg. Macro in Proc Format

If i need both in same name how to write in macro.
Contributor
Posts: 23

Re: Reg. Macro in Proc Format

Something like the following should work for you:

[pre]
OPTIONS MPRINT;

%MACRO CountryFmts (COUNTRY= );
%IF %UPCASE(&COUNTRY) = INDIA %THEN %DO;
'0002' = 'Customer minimum age'
'0009' = 'Vehicle age and term'
'0013' = 'Unavailable'
'0029' = 'Advance > E35000'
%END;
%ELSE %IF %UPCASE(&COUNTRY) = PAKISTAN %THEN %DO;
'0002' = 'Customer Age < 18 or > 70'
'0009' = 'Vehicle Age + Term > 6 years'
'0013' = 'Incomplete bureau search'
%END;
%ELSE %DO;
/* Neither INDIA nor PAKISTAN specified -- possible error */
%END;
%MEND CountryFmts;

PROC FORMAT;
VALUE $polrule
'0000' = 'none'
'0001' = 'Customer Age Range'
'0037' = 'Military service not completed'
'0058' = 'Employee'
'0097' = 'Five year finance low deposit'
'0132' = 'Employment Type'
'0141' = 'Self Employed'
%CountryFmts (COUNTRY=INDIA)
;
RUN;

/* or, in a different job */
PROC FORMAT;
VALUE $polrule
'0000' = 'none'
'0001' = 'Customer Age Range'
'0037' = 'Military service not completed'
'0058' = 'Employee'
'0097' = 'Five year finance low deposit'
'0132' = 'Employment Type'
'0141' = 'Self Employed'
%CountryFmts (COUNTRY=Pakistan)
;
RUN;
[/pre]
Message was edited by: MikeRhoads at Jan 18, 2007 1:11 PM
Ask a Question
Discussion stats
  • 3 replies
  • 138 views
  • 0 likes
  • 3 in conversation