data s3;
set t2;
by type;
if first.type
then
do;
mc=0,fc=0;
if gender=M
then
mc+1;
else
fc+1;
end;
if last.type
then output;
log
Can you be more descriptive about your problem.
Like what is your input, what is expected output and what problem are you facing.
Do share sas code that you are using.
data a1;
input household $ type $;
datalines;
A Savings
A Pension
A Investment
B Term
B Pension
B Investment
C term
C Pension
run;
data a2;
input household $ customer $ gender $;
datalines;
A Ken M
A Seni F
B Fab M
C Ron M
C Mary F
run;
Proc sql;
create table t2
as select a.household,a.type ,
b.gender
from a1 as a,a2 as b
where a.household=b.household;
quit;
proc sort data=t2;
by type;
run;
data s3;
set t2;
by type;
if first.type
then
do;
mc=0,fc=0;
if gender=M
then
mc+1;
else
fc+1;
end;
if last.type
then output;
proc sql;
create table t3 as
select type_of_product,gender
from t2;
when
quit;
i have 2 tables a1 and a2,
i have merged them and now i want the count no of males and females based on the type.
nd based on that decide whether they are male biased or female biased for each type.
This "statement" is the culprit:
mc=0,fc=0;
I guess you wanted
mc=0;
fc=0;
It will help if you post your log using the box provided from the "run" icon in the menu bar. It will preserve most of the text formatting and show the underline of the offending code. See this for an example of an error message from the log
2115 proc means data=work.meanstest stackods n sum mean;
--------
22
202
ERROR 22-322: Syntax error, expecting one of the following: ;, (, ALPHA, CHARTYPE, CLASSDATA,
CLM, COMPLETETYPES, CSS, CV, DATA, DESCEND, DESCENDING, DESCENDTYPES, EXCLNPWGT,
EXCLNPWGTS, EXCLUSIVE, FW, IDMIN, KURTOSIS, LCLM, MAX, MAXDEC, MEAN, MEDIAN, MIN,
MISSING, MODE, N, NDEC, NMISS, NOLABELS, NONOBS, NOPRINT, NOTHREADS, NOTRAP, NWAY,
ORDER, P1, P10, P25, P5, P50, P75, P90, P95, P99, PCTLDEF, PRINT, PRINTALL,
PRINTALLTYPES, PRINTIDS, PRINTIDVARS, PROBT, Q1, Q3, QMARKERS, QMETHOD, QNTLDEF,
QRANGE, RANGE, SKEWNESS, STDDEV, STDERR, SUM, SUMSIZE, SUMWGT, T, THREADS, UCLM,
USS, VAR, VARDEF.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
Also I am VERY puzzled by your coding style of breaking if then do into 3 code lines but then attempting to combine two statements on a single line. Possibly if you had posted the code using the "run" icon there was formatting that would have helped make the poste readable.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.