SAS: how to properly use intck() in proc sql -


i have following codes in sas:

proc sql; create table play2 select a.anndats,a.amaskcd,count(b.amaskcd) experience test1 a, test1 b a.amaskcd = b.amaskcd , intck('day', b.anndats, a.anndats)>0 group a.amaskcd, a.anndats; quit;

the data test1 has 32 distinct obs, while play2 returns 22 obs. want each obs, count number of appearance same amaskcd in history. best way solve this? thanks.

the reason return 22 observations - might not 22 distinct 32 - comma join, in case ends being inner join. given row a if there no rows b have later anndats same amaskcd, a not returned.

what want here left join, returns rows a once.

create table play2   select ...   test1   left join test1 b   on a.amaskcd=b.amaskcd   intck(...)>0   group ... ; 

i write differently, i'm not sure above want.

create table play2   select a.anndats, a.amaskcd,     (select count(1) test1 b        b.amaskcd=a.amaskcd        , b.anndats>a.anndats  /* intck('day') pointless, dates stored integer days */     ) experience     test1     ; 

if test1 isn't grouped amaskcd , anndats, may need rework some. kind of subquery easier write , more accurately reflects you're trying do, suspect.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -