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.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 10417 views
  • 1 like
  • 3 in conversation