Architecting, installing and maintaining your SAS environment

Conversion sql to data step

Accepted Solution Solved
Reply
Contributor
Posts: 71
Accepted Solution

Conversion sql to data step

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


Accepted Solutions
Solution
‎09-13-2013 02:43 AM
Super Contributor
Posts: 297

Re: Conversion sql to data step

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


All Replies
Respected Advisor
Posts: 4,173

Re: Conversion sql to data step

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;

...

Contributor
Posts: 71

Re: Conversion sql to data step

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.

Solution
‎09-13-2013 02:43 AM
Super Contributor
Posts: 297

Re: Conversion sql to data step

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;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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