BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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.
3 REPLIES 3
Olivier
Pyrite | Level 9
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.
deleted_user
Not applicable
If i need both in same name how to write in macro.
MikeRhoads
Obsidian | Level 7
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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