BookmarkSubscribeRSS Feed
jashu14
Calcite | Level 5

I want to create a dummy row using proc SQL.

 

In the below example we can get male and female count.

 

And for that GENDER we usually create a dummy data set and set back. So is it possible do the same using proc SQL.

 

For Example :

 

Gender

          Male        2

          Female    3

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16
proc sql;
   create table dummy
       (Gender char(10),
        count num(8)
        );

insert into dummy
    values('Female',3)
    values('Male',2);
	 
quit;
Thanks,
Jag
Kurt_Bremser
Super User

Do you mean that you want to create a count of observations for the two possible values of gender?

 

A SQL approach would be

proc sql;
create table want as
select
  'Male' as gender length = 6,
  count(*) as count
from have
where gender = 'Male'
union all
select
  'Female' as gender,
  count(*)
from have
where gender = 'Female'
;
quit;

Note that this is very much a waste of code space and performance as this will do the same:

proc freq data=have noprint;
table gender / out=want (drop=percent);
run;

See Maxim 14.