posted this previously, the solution offered does not work.
have a dataset that looks like this, about 100,000 rows of unique data
vendor is a unique 6 digit numeric and dte is the date of processing as
mmddyy6,
a single vendor appears only once per day but may or may not occur every day
of the month.
vendor, dte
122123 010111
122129 010111
122100 010111
133932 010111
I want to calculate number of times this year (y) and how may times in last
60 to 90 days, but I get a subgroup error in the log
expected output similar to:
vendor=122123 dte=010111 y=1 _6090_=1
proc sql;
create table test as select vendor,dte, count(*) as y,
(select count(*) from vend_data where
(intnx('day',date(),-60 < dte >= intnx('day',date(),-90) )
group by vend_data ) as _6090_
from vend_data
group by vendor;
|
|
0
|
|
|
|
Reply
|
mark
|
3/23/2011 11:50:32 AM |
|
On Mar 23, 4:50=A0am, "mark" <m...@mailinator.com> wrote:
> posted this previously, the solution offered does not work.
>
> have a dataset that looks like this, about 100,000 rows of unique data
>
> vendor is a unique 6 digit numeric and dte is the date of processing as
> mmddyy6,
> a single vendor appears only once per day but may or may not occur every =
day
> of the month.
>
> vendor, dte
> 122123 010111
> 122129 010111
> 122100 010111
> 133932 010111
>
> I want to calculate number of times this year (y) and how may times in la=
st
> 60 to 90 days, but I get a subgroup error in the log
>
> expected output similar to:
> vendor=3D122123 dte=3D010111 y=3D1 _6090_=3D1
>
> proc sql;
> create table test as select vendor,dte, count(*) as y,
> (select count(*) from vend_data where
> =A0 =A0(intnx('day',date(),-60 < dte >=3D intnx('day',date(),-90) )
> =A0 =A0 group by vend_data ) as _6090_
> from vend_data
> =A0group by vendor;
Use a subselect instead.
ie proc sql;
create table ...
select a.*, b._6090_
from have a
left join (this should be a sub select that contains the count for
60-90 days by vendor) b
on a.vendor=3Db.vendor;
quit;
In SAS you can subtract dates ie date()-dte to get the difference
which is easier to deal with than then intnx function sometimes. Your
choice though really.
And again, check your brackets, they don't match up.
|
|
0
|
|
|
|
Reply
|
Reeza
|
3/23/2011 5:56:14 PM
|
|
>>
Use a subselect instead.
ie proc sql;
create table ...
select a.*, b._6090_
from have a
left join (this should be a sub select that contains the count for
60-90 days by vendor) b
on a.vendor=b.vendor;
quit;
>>
your proposed solution does not result in the wanted output
|
|
0
|
|
|
|
Reply
|
mark
|
3/26/2011 3:29:23 PM
|
|
On Mar 26, 11:29=A0am, "mark" <m...@mailinator.com> wrote:
> Use a subselect instead.
> ie proc sql;
> create table ...
> select a.*, b._6090_
>
> from have a
> left join (this should be a sub select that contains the count for
> 60-90 days by vendor) b
> on a.vendor=3Db.vendor;
> quit;
>
>
>
> your proposed solution does not result in the wanted output
Mark - The suggestion was just a framework for a solution. Can you
post what actual code you tried?
Perhaps someone can can improve it.
Are you sure that you have actual DATE variables with a SAS format
attached? Or do you have character variable (or even a numeric
variable) that just LOOKS like it has a date in it?
|
|
0
|
|
|
|
Reply
|
tom.abernathy (199)
|
4/3/2011 7:14:18 PM
|
|
|
3 Replies
440 Views
(page loaded in 0.076 seconds)
|