- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 03-03-2011 04:20 PM
(1548 views)
Hi,
Currently, I am having two proc sql statement where one get's the count of the data and the other sql query creates a new table based on that count. I am trying to create a macro as both the query as same but not able to figure how can I achieve both results?
Any suggestions would be highly appreciated.
Currently, I am having two proc sql statement where one get's the count of the data and the other sql query creates a new table based on that count. I am trying to create a macro as both the query as same but not able to figure how can I achieve both results?
Any suggestions would be highly appreciated.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello Pritish,
If you would like a detailed answer, please give an example of data, desired result and your code.
Sincerely,
SPR
If you would like a detailed answer, please give an example of data, desired result and your code.
Sincerely,
SPR
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
1.
proc sql;
select count (distinct emp) into: emp_cnt
from emp;
quit;
2.
proc sql;
create table emp_new as
select count (distinct emp) as emp_cnt
from emp;
quit;
I have this two queries. I want to avoid unnecessary code so trying to go for Macro. Message was edited by: Pritish
proc sql;
select count (distinct emp) into: emp_cnt
from emp;
quit;
2.
proc sql;
create table emp_new as
select count (distinct emp) as emp_cnt
from emp;
quit;
I have this two queries. I want to avoid unnecessary code so trying to go for Macro. Message was edited by: Pritish
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't really see a macro being necessary to accomplish this task.
data emp_new;
set emp end=eof;
if eof=1 then do;
emp_cnt=_N_;
call symput('emp_cnt',emp_cnt);
keep emp_cnt;
output;
end;
run;
The above should create dataset emp_new containing one column (emp_cnt) and one row containing the count of rows in emp, while also putting the count into variable &emp_cnt. Above is untested but assumed to work. Message was edited by: mkastin
data emp_new;
set emp end=eof;
if eof=1 then do;
emp_cnt=_N_;
call symput('emp_cnt',emp_cnt);
keep emp_cnt;
output;
end;
run;
The above should create dataset emp_new containing one column (emp_cnt) and one row containing the count of rows in emp, while also putting the count into variable &emp_cnt. Above is untested but assumed to work. Message was edited by: mkastin