BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Babloo
Rhodochrosite | Level 12

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;

*/

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

%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);

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User

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;


Babloo
Rhodochrosite | Level 12

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!

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Kurt_Bremser
Super User

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.

Babloo
Rhodochrosite | Level 12

May I request you to provide some example code?

Kurt_Bremser
Super User

%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);

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 1244 views
  • 6 likes
  • 4 in conversation