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.

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 10595 views
  • 1 like
  • 3 in conversation