BookmarkSubscribeRSS Feed
rishabhmehra13
Calcite | Level 5

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

 

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56
57 data s3;
58 set t2;
59 by type;
60 if first.type
61 then
62 do;
63 mc=0,fc=0;
_
388
200
ERROR 388-185: Expecting an arithmetic operator.
 
ERROR 200-322: The symbol is not recognized and will be ignored.
 
64
65 if gender=M
66 then
67 mc+1;
68 else
69 fc+1;
70 end;
71 if last.type
72 then output;
73
74 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
WARNING: The data set WORK.S3 may be incomplete. When this step was stopped there were 0 observations and 6 variables.
WARNING: Data set WORK.S3 was not replaced because this step was stopped.
86
4 REPLIES 4
RahulG
Barite | Level 11

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.

rishabhmehra13
Calcite | Level 5

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.

ballardw
Super User

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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 1314 views
  • 2 likes
  • 4 in conversation