stats unique

For making suggestions and/or requests for new features you'd like added to EViews.

Moderators: EViews Gareth, EViews Moderator

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

stats unique

Postby startz » Tue Aug 12, 2014 10:16 am

It would be nice if stats and statsby had an option to count the number of unique values. For example, I have teacher ids and I'd like to know how many teachers were in each grade.

EViews Glenn
EViews Developer
Posts: 2671
Joined: Wed Oct 15, 2008 9:17 am

Re: stats unique

Postby EViews Glenn » Thu Aug 14, 2014 7:42 am

How about

Code: Select all

series uniqueids = @sumsby(1, grade)

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: stats unique

Postby startz » Thu Aug 14, 2014 7:46 am

EViews Glenn wrote:How about

Code: Select all

series uniqueids = @sumsby(1, grade)

I think that gives me the number of observations in each grade. I want to know how many teachers are in each grade, where observations are on students and a number of students have the same teacher.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13294
Joined: Tue Sep 16, 2008 5:38 pm

Re: stats unique

Postby EViews Gareth » Thu Aug 14, 2014 7:46 am

That doesn't do what he wants, I think.

You need the cross of unique vals.
Follow us on Twitter @IHSEViews

EViews Glenn
EViews Developer
Posts: 2671
Joined: Wed Oct 15, 2008 9:17 am

Re: stats unique

Postby EViews Glenn » Thu Aug 14, 2014 7:47 am

Yeah. Just saw that when I reread it; was about to edit my post but you beat me to it. I was trying to think of how to do it with @uniquevals but then got distracted and when I came back it seemed so obvious :)

[edit] You should be able to get it with n-way tabulation but that requires some manual computation and doesn't link back to the obs in the workfile.

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: stats unique

Postby startz » Thu Aug 14, 2014 8:48 am

In the application at hand, I have about 13,000 observations and 1,000 teachers. So I'd rather not produce a list of unique teacher ids. What I did was

Code: Select all

smpl if grade="G0"
scalar teachCount = @rows(@uniquevals(tchid))


and then repeated the code for different smpl if conditions. But an addition to stats would be nice.

EViews Glenn
EViews Developer
Posts: 2671
Joined: Wed Oct 15, 2008 9:17 am

Re: stats unique

Postby EViews Glenn » Thu Aug 14, 2014 4:42 pm

Fair enough. Just wanted to make sure you could get your work done for now. A @ranksby and related functions would similarly be useful.


Return to “Suggestions and Requests”

Who is online

Users browsing this forum: No registered users and 8 guests