07-19-2016 06:21 PM - edited 07-21-2016 02:52 AM
I tried to make a macro with one variable where one can define quantile (e.g. flag data with appropriate mark - for example: in case it belongs to the lowest decile as Q10, etc.). The script does not store all values of i, it goes from 1 to the defined number N but then only stores the last result (i.e. N), any suggestions how to keep all values of i and thus gain all cases?:
%DO i=1 %TO &N.;
CREATE TABLE G AS
CASE WHEN VAR2 <= (1-(&i-1)/10) * MAX(VAR2) AND VAR2> (1-&i/10) * MAX(VAR2) THEN "Q&i" END AS FLAG
Thanks for any suggestions.
07-19-2016 06:28 PM - edited 07-19-2016 06:29 PM
Many ideas, but just one suggestion to start. Get the program to work by hard-coding everything, without using macro language. Once it is working, we can look at converting it into a macro.
Unless you do that, you will have to debug both SAS language errors and macro language errors at the same time ... a much more difficult task.
07-19-2016 07:35 PM
And proc rank wouldn't work either?
If you want indicators for deciles you'll need to transpose the final table but again it's fully dynamic without macros.