- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm working on a cross sell campaign which was conducted by one bank. They sold products like home loan, personal loan, debit card loan and mortgage loan.However product sold was not identical for each month.
Example: they sold home loan, personal loan, debit card loan and mortgage loan for Jan month. For Feb month product sold was home loan, debit card loan and mortgage loan.Please be informed that they sold maximum of three\four products per month.
I managed to complete the report generation (via merge,macros and proc report) to determine the status of cross sell campaign for January. Now I need to work on reports for February month whereas I need to comment out the data steps,macros which has debit card loan since they sold only home loan, debit card and mortgage loan. Any possibilities to make this logic static by changing only the product name at the initial step ( in %let statement) rather than commenting out each step which holds the product that is not required.
Please see my code snippet below for February month. You can see that I'm commenting all the parts connected with personal loan. Likewise there are many steps in my code. So any inputs to this threat is greatly appreciated.
%let Actfile = strat_fullacct_12312013.csv ;*** App File ;
%let mciffile = strat_fullacct_07182014_cass.csv ;*** Customer base file ;
%let dcfile = WB_D1_DEBIT_CONTROL_revised.csv ;*** Debit card control file ;
%let plcfile = /*WB_D1_TU_PLOAN_CONTROL_revised.csv ;*** Personal loan control file ;
%let ctlfile = controlclpjan_sept2014_10202014.csv;
****************Merge WISC mail file and MCIF file to produce the direct responses;
/*Proc Sort data=&clint.mfile_WIS_C out=&clint.mfile_WIS_C_sorted;
by CONKEY;
run;
Proc Sort data=&clint.mcif_unmat2_PL out=&clint.mcif_unmat2_sorted;
by conkey;
run;
Data rpt.&clint._WISC_dirresp_&outdt;
merge &clint.mfile_WIS_C_sorted(In=aa )
&clint.mcif_unmat2_sorted(In=bb drop=N_ADDRESS N_STATE N_ZIP Full_Name );
by CONKEY;
if aa & bb then
do;
format acctnum_prod $30. nbr_acct 1.;
acctnum_prod =compress(upcase(ACCOUNT_NUMBER||Product_code));
control_flag=0;
camp_flag = &outdt;
nbr_acct = 1;
if (&maildate+7 <= date_OPEN <= &maildate+97) and TRIM(Prod_grpm)=TRIM(Prod_grp) then
DO;
MATCHED='Y';
resptype = 'direct';
dmatch_mail=1;
END;
end;
iF prod_flag ne '4';
if aa then
output;
run;
Proc Sort data=rpt.&clint._WISC_dirresp_&outdt out=&clint._WISC_dirresp_sorted;
by conkey;
run;
*/
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
%let appfile =<None>;
%macro do_work(infilename);
%if "&infilename" ne "<NONE>" %then %do;
proc import datafile="&infilename." out=appfile_cass dbms=CSV replace;
guessingrows=30000;
run;
data want;
set appfile_cass;
run;
%end;
%mend;
%do_work(&appfile);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You could probably just make data set related to that type of data with 0 observations and not need to eliminate any of the code.
%let dcfile = WB_D1_DEBIT_CONTROL_revised.csv ;*** Debit card control file ;
%let dcfile = <NONE> ;
data dcdata ;
if "&dcfile" = "<NONE>" then stop;
input "&dcfile" .... ;
input .....
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your response.
However, I'm not sure fit your code for proc import. See my code below.
/* working*/
%let appfile =/data/PPM/Spatial_Analysis/fcu_combined_mf_201411_cass.csv; /*termstr=crlf lrecl=32760 ;*/
proc import datafile="&appfile." out=appfile_cass dbms=CSV replace;
guessingrows=30000;
run;
data want;
if "&appfile." = "<NONE>" then stop;
else;
set appfile_cass;
run;
/* not working - because proc import search for the file "<NONE>" in server */
%let appfile =<None>;
proc import datafile="&appfile." out=appfile_cass dbms=CSV replace;
guessingrows=30000;
run;
data want;
if "&appfile." = "<NONE>" then stop;
else;
set appfile_cass;
run;
Please suggest to overcome this error. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Well, firstly I would recommend not using proc import, use a datastep and infile statement to ensure you have complete control over your import.
Secondly, are you checking for the existence of the file before doing things? If so then:
data _null_;
if %sysfunc(fileexist(&APPFILE.)) = 1 then do;
call execute('proc import datafile="&appfile." out=appfile_class...; run;');
end;
run;
You could also do it in a macro.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Encapsulate the steps in question in a macro and a %if "&flag" = "value" %then %do; your code %end; block.
Then you only need to check conditions and set the flags at the beginning and then call the macros.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
May I request you to provide some example code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
%let appfile =<None>;
%macro do_work(infilename);
%if "&infilename" ne "<NONE>" %then %do;
proc import datafile="&infilename." out=appfile_cass dbms=CSV replace;
guessingrows=30000;
run;
data want;
set appfile_cass;
run;
%end;
%mend;
%do_work(&appfile);