BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pallis
Fluorite | Level 6

proc sql;

create table a

as

select   

        Deptno,

        STATUS,   

        Count(AGMTNO)

from Emp_aug13_Data

group by

            Deptno ,      

            STATUS;

quit;


Can you help me how can achive this in data step


regards,

venky

1 ACCEPTED SOLUTION

Accepted Solutions
Scott_Mitchell
Quartz | Level 8

Is it necessary to use a datastep?  Of course it can be done, but you could also use PROC FREQ:

PROC FREQ DATA=EMP_AUG13_DATA NOPRINT;

TABLES DEPTNO * STATUS / OUT=WANT(DROP=PERCENT) ;

RUN;

View solution in original post

3 REPLIES 3
Patrick
Opal | Level 21

Is this an exercise? Or why else would you want to do this?

First sort your data by deptno and status, then in a data step use by group processing.

...

by deptno status;

count+1;

if last.status then

do;

output;

count=0;

end;

...

pallis
Fluorite | Level 6

Yes I'm an sql programmer and I was moved to sas recently. The task given by team is that. I could do things and get  results in sql  But they are rejecting and asking me to us in data step. I'm unable to figure out the thing how to do in sas Smiley Wink . So I thought this is way I can learn and implement when it comes next time.

Regards,

venky.

Scott_Mitchell
Quartz | Level 8

Is it necessary to use a datastep?  Of course it can be done, but you could also use PROC FREQ:

PROC FREQ DATA=EMP_AUG13_DATA NOPRINT;

TABLES DEPTNO * STATUS / OUT=WANT(DROP=PERCENT) ;

RUN;

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1173 views
  • 3 likes
  • 3 in conversation