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

Please kindly me help me with SAS syntax correct for each line.

Like line1 with the lack of '%' before let statement.Thank you for your attention

 

proc sql;
create table acct_purc_stat_m nologging as
select acct,sum(txn_amt_rmb) purc_amt
from ccm_base_trans
where plus_minus_flag=1 and txn_type='01' and org='242'
and "1may2015:00:00:00"dt <=eff_date<="31may2015:00:00:00"dt
group by acct
order by acct;
run;

1.%let var=%str(sex age edu_degree mob actv_flag circ_flag credit_limit otb ar);
let var=%str(sex age edu_degree mob actv_flag circ_flag credit_limit otb ar);
2.
proc sort data=ccm_expd(keep &var. where=(circ_flag='1'))
3.
out = acct_act_m;
4.
class acct;
run;

data acct_base_inf;
5.
	merge acct_act_m(in=a) acct_purc_stat_m(in=b);
6.
	if a;
7.
	used_rate=ifc(credit_limit in (0,.),0,ar/credit_limit);
run;

proc freq data=acct_base_inf;
	by sex edu_degree actv_flag circ_flag/missing;
run;

proc univariate data=acct_base_ing missing;
	var age mob credit_limit otb ar used_rate;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

You already know the answer for %LET.

 

For #2, when KEEP is used as a data set option inside parentheses, it requires an equal sign:  keep=

 

For #3, nothing wrong.

 

For #4, there is no such thing as a CLASS statement in PROC SORT.  It should become a BY statement instead.

 

For #5 through #7, it is highly likely that the program should add a BY statement after the MERGE statement:  by acct;

 

PROC FREQ is allowed to use a BY statement.  But most likely the intent is to use a TABLES statement instead of a BY statement.

 

PROC UNIVARIATE does not allow the MISSING option on the PROC statement.  If you had a CLASS statement, the MISSING option could be part of that statement.

View solution in original post

3 REPLIES 3
Shmuel
Garnet | Level 18

Can you run your code and post the log?

ccnky123
Calcite | Level 5
thank you for your time.I have already got the answer from syntax only
Astounding
PROC Star

You already know the answer for %LET.

 

For #2, when KEEP is used as a data set option inside parentheses, it requires an equal sign:  keep=

 

For #3, nothing wrong.

 

For #4, there is no such thing as a CLASS statement in PROC SORT.  It should become a BY statement instead.

 

For #5 through #7, it is highly likely that the program should add a BY statement after the MERGE statement:  by acct;

 

PROC FREQ is allowed to use a BY statement.  But most likely the intent is to use a TABLES statement instead of a BY statement.

 

PROC UNIVARIATE does not allow the MISSING option on the PROC statement.  If you had a CLASS statement, the MISSING option could be part of that statement.

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