Programming the statistical procedures from SAS

sas programming

Reply
Occasional Contributor
Posts: 17

sas programming

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

PROC Star
Posts: 736

Re: sas programming

Posted in reply to vinod4842

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? Smiley Happy

Ask a Question
Discussion stats
  • 1 reply
  • 110 views
  • 0 likes
  • 2 in conversation