Dear All,
Is it possible to order the series.freq (one way tabulation) by count rather than alphabetically by alpha name?
Thanks!
Charlie
order .freq by count
Moderators: EViews Gareth, EViews Moderator
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13319
- Joined: Tue Sep 16, 2008 5:38 pm
-
- Posts: 202
- Joined: Tue Jul 17, 2012 9:47 am
Re: order .freq by count
now it is possible:
Code: Select all
subroutine frequencytab(alpha inputalpha)
freeze(inputalpha_tab) inputalpha.freq(nocum,nolimit)
!numberunique=@rows(@uniquevals(inputalpha))
wfcreate(wf=frequencytabulated) u !numberunique
copy alldatasets::inputalpha_tab frequencytabulated::inputalpha_tab
alpha uniquevalues = ""
genr uniquevaluefreq = NA
for !y = 1 to !numberunique
uniquevalues(!y) = inputalpha_tab(7+!y,1)
uniquevaluefreq(!y) =@val(inputalpha_tab(7+!y,2))
next
group tabber uniquevaluefreq uniquevalues
tabber.sort(-1)
freeze(freqtab) tabber
copy frequencytabulated::freqtab alldatasets::freqtab
freqtab.deletecol(a) 1
wfclose frequencytabulated
d inputalpha_tab
endsub
-
- Posts: 202
- Joined: Tue Jul 17, 2012 9:47 am
Re: order .freq by count
Better to endogenously pull out the wf name - cleaner:
Code: Select all
subroutine frequencytab(alpha inputalpha)
%wfnameholder = @wfname
freeze(inputalpha_tab) inputalpha.freq(nocum,nolimit)
!numberunique=@rows(@uniquevals(inputalpha))
wfcreate(wf=frequencytabulated) u !numberunique
copy {%wfnameholder}::inputalpha_tab frequencytabulated::inputalpha_tab
alpha uniquevalues = ""
genr uniquevaluefreq = NA
for !y = 1 to !numberunique
uniquevalues(!y) = inputalpha_tab(7+!y,1)
uniquevaluefreq(!y) =@val(inputalpha_tab(7+!y,2))
next
group tabber uniquevaluefreq uniquevalues
tabber.sort(-1)
freeze(freqtab) tabber
copy frequencytabulated::freqtab {%wfnameholder}::freqtab
wfclose frequencytabulated
d inputalpha_tab
endsub
Return to “General Information and Tips and Tricks”
Who is online
Users browsing this forum: No registered users and 18 guests