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;
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.
Can you run your code and post the log?
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.