BookmarkSubscribeRSS Feed
vinod4842
Fluorite | Level 6

data ds;
infile datalines;
input id$ name$ age sex$;
datalines;
101 vinod 22 m
102 kumar 23 m
103 suresh 24 m
104 kalesh 25 m
105 firek 26 f
109 haiek 24 f
;
run;

proc sql;
create table work.ds1 as SELECT 'Total' AS id,count(name) AS name, count(age) as age, count(sex) as sex FROM work.ds

GROUP BY age;
run;

data ds2;
set ds ds1;
run;

 

223 data ds;
224 infile datalines;
225 input id$ name$ age sex$;
226 datalines;

NOTE: The data set WORK.DS has 6 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


233 ;
234 run;
235
236 proc sql;
237 create table work.ds1 as SELECT 'Total' AS id,count(name) AS name, count(age) as age, count(sex)
237! as sex FROM work.ds
238
239 GROUP BY age;
NOTE: Table WORK.DS1 created, with 5 rows and 4 columns.

240 run;
NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.
241
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


242 data ds2;
243 set ds ds1;
ERROR: Variable name has been defined as both character and numeric.
ERROR: Variable sex has been defined as both character and numeric.
244 run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.DS2 may be incomplete. When this step was stopped there were 0
observations and 4 variables.
WARNING: Data set WORK.DS2 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

 

 

 

i want to addup the two datasets of subgroups and grand total also

plz rectify

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

The error occurs because in ds, the variable name is character and in ds1 it is numeric due to the count calculation in your sql step.

 

What exactly do you want your ds2 to look like? 🙂

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1194 views
  • 0 likes
  • 2 in conversation