On Fri, 20 Sep 2019, Alecos Papadopoulos wrote:
 1) I have a series X characterized as discrete, with 9 unique values,
one of 
 them negative the other positive. When I execute
 dummify X
 I get all 9 dummies that the command should produce.
 I found out that I can also execute
 list dumXlist = dummify(X)
 ...but in which case the command does not produce the dummy_1, 
 related to the negative value, and so the dumXlist contains only 8 
 dummies. Note: the dummies that are produced are labelled 
 correctly, namely their names start from DX_2, DX_3 etc. So Gretl 
 tells me "I know there is one more dummy in there, but I won't 
 create it"... is this a bug? 
Perhaps. But one would not usually expect a series that encodes a 
qualitative characteristic to include negative values. It would be 
easy enough to transform the source series to use only non-negative 
values.
 2) I was unable to determine the combination of Gretl commands that
will give 
 me the following:
 Let X be a series, X(i), i=1,...,n. I want to create the following series
 Y(i) = "the immediately smaller value than X(i) in the X series".
 (If the Y series is created using a loop, I guess I can deal with what 
 happens when X(i) is the minimum value in the series by an "if" command)
 E.g. if the X series has unique values {-3,  -1,     5,   17}, then X(i) = 5 
 => Y(i) = -1, X(j) = -1 => Y(j) = -3,   etc. 
I'm not sure what you mean by "the immediately smaller value". What 
should happen if X(i-1) is not smaller than X(i)? Or if there's no 
value X(i-p) that is smaller than X(i) for p >= 1? It seems to me 
you need to think this through some more.
That said, you may want to use a double loop such that for each X(i) 
you search backward (i-1, i-2, ..., 1) for a smaller X value to put 
into Y(i), and failing that, NA. Something like this:
<hansl>
Y[1] = NA
loop i=2..n --quiet
     Y[i] = NA
     loop for (j=i-1; j>0; j--)  --quiet
         if X[j] < X[i]
             Y[i] = X[j]
             break
         endif
     endloop
endloop
</hansl>
Allin Cottrell