BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Geo-
Quartz | Level 8

Anyone knows how to fix this macro?It probably do with date format problem. In the attachment is data set sample .thank you for your time.

 

 

%macro sum_txn_inf(stat_dt);
%let mbeg=%sysfunc(intnx(month,&stat_dt.,0,begin),data9.);
%let mend=%sysfunc(intnx(month,&stat_dt.,0,end),data9.);
%let mon=%sysfunc(putn(&stat_dt.,yymmn4.));

data _txn_dtl_inf;
	if _n_=0 then set acct_list;
	if _n_=1 then do;
		declare hash hh(dataset:"acct_list");
		hh.definekey("acct");
		hh.definedata("acct");
		hh.definedone();
	end;

	set CCM_BASE_TRANS(keep=stat_date eff_date txn_type txn_amt_rmb
						where=("&mbeg. :00:00:00"dt le stat_date le "&mend. :00:00:00"dt
						and "&mbeg. :00:00:00"dt le eff_date le "&mend. :00:00:00"dt));
	format eff_dt yymmdd10.;
	eff_dt=datepart(eff_date);
	if hh.find()=0;
run;

proc summary data=_txn_dtl_inf nway missing;
	class eff_date txn_type;
	var txn_amt_rmb;
	output out=_txn_type_sum(drop=_:)
		sum=txn_amt_&mon.;
run;

proc sort data=_txn_type_sum out=txn_type_sum_&mon.;
	by eff_dt txn_type;
run;

%mend;

%sum_txn_inf("01may2015"d);

acct_list:

acct
1
2
3
4

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

The variable is called eff_date in the proc summary step.

PG

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

i see a typo

%let mbeg=%sysfunc(intnx(month,&stat_dt.,0,begin),data9.);
%let mend=%sysfunc(intnx(month,&stat_dt.,0,end),data9.);

in the above data9. should be date9.

 

 

SASKiwi
PROC Star
%let mbeg=%sysfunc(intnx(month,&stat_dt.,0,begin),date9.);
%let mend=%sysfunc(intnx(month,&stat_dt.,0,end),date9.);

 

Getting rid of these blanks should help:

 

where=("&mbeg.:00:00:00"dt le stat_date le "&mend.:00:00:00"dt
and "&mbeg.:00:00:00"dt le eff_date le "&mend.:00:00:00"dt
Geo-
Quartz | Level 8
there is still an error"could not find variable eff_dt" in proc sort statement.Why ?
PGStats
Opal | Level 21

The variable is called eff_date in the proc summary step.

PG

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 987 views
  • 1 like
  • 4 in conversation