Hi Statalist,

I can't seem to fulfill the following in stata, perhaps one of you would know the answer:

I have a panel data of public firms with their stock prices. For every firmid (permno) I counted the observation from the first date on with:
Code:
by permno: gen n=_n
So I could drop observations if altprc(pricevariable) was missing & n would be equal to 1 with:
Code:
drop if altprc==. &n==1
This worked out great, but now I want to drop if the price is missing & the n count is the last one for each firm. Now the problem is that each firm has a different _n, so the previous code will not work.
I wanted to quietly sum n for every firm, so I could set the max value of n for every firm & then drop it. but apparently one cant use quietly with sum.
I tried to the following: but this give me a syntax error.
Code:
by permno: quietly sum n
I also dont want to dleete all observations of the firm if the condition is met. I just want to delete that last "row''
My dataexample is as following:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(permno altprc) float n
10001     6.25   1
10001     6.75   2
10001    6.125   3
10001   6.3125   4
10001   6.4375   5
10001     6.25   6
10001   6.4375   7
10001    6.625   8
10001    6.375   9
10001    6.625  10
10001    6.625  11
10001    6.375  12
10001      6.5  13
10001     6.75  14
10001     6.75  15
10001     7.25  16
10001        7  17
10001        7  18
10001     7.25  19
10001     9.25  20
10001    8.875  21
10001      9.5  22
10001    9.875  23
10001   10.125  24
10001   9.9375  25
10001    9.875  26
10001    9.875  27
10001    9.875  28
10001     9.75  29
10001     9.75  30
10001       10  31
10001      9.5  32
10001     9.75  33
10001    9.625  34
10001    9.625  35
10001      9.5  36
10001    9.625  37
10001     9.75  38
10001      9.5  39
10001    9.875  40
10001    9.875  41
10001     10.5  42
10001   10.125  43
10001     11.5  44
10001     11.5  45
10001       13  46
10001    14.75  47
10001     14.5  48
10001    13.75  49
10001       11  50
10001    11.75  51
10001   11.875  52
10001       12  53
10001    11.75  54
10001     12.5  55
10001       13  56
10001       15  57
10001   14.625  58
10001   14.375  59
10001       14  60
10001       14  61
10001    14.25  62
10001    14.25  63
10001    15.25  64
10001   15.125  65
10001     16.5  66
10001   16.375  67
10001   15.875  68
10001    16.75  69
10001    17.25  70
10001       17  71
10001   18.375  72
10001     17.5  73
10001     17.5  74
10001    17.25  75
10001    14.75  76
10001    15.75  77
10001    8.625  78
10001     9.25  79
10001        9  80
10001     9.25  81
10001     8.75  82
10001    8.375  83
10001        8  84
10001     7.75  85
10001 7.546875  86
10001      7.5  87
10001      7.5  88
10001    7.875  89
10001     8.25  90
10001     8.25  91
10001        8  92
10001     8.25  93
10001        8  94
10001     8.75  95
10001    9.375  96
10001    9.125  97
10001     9.25  98
10001 9.484375  99
10001   8.8125 100
end
Thanks in advance.
Best,
Arslan