Hi,
I have a dataset with 96 variables and 28 observations per variable.
I would like to run the nlp procedure for each variable.
I am having difficulty doing so. (I am very new to SAS)
The equation and data are the same for each run of nlp procedure. I just need to change one variable (called certain) each run through.
In the end I would like to have 96 different estimates for alpha and gamma.
I have set up the nlp proc in a macro with an input variable.
I am not sure how to get the variables that I need from the data set one at a time and pass them into the macro.
Please help!
I have included what I am trying, unsuccessfully, to do below....
THanks, Jen
/* This is the macro called nlp test
the variable 'certain' needs to change 96 times
THe equation works if I run it using one variable, the issue is when i try to loop through multiple variables...*/
%macro nlptest(certain);
proc nlp data=Work.Prospect;
lsq z;
parms alpha=1, gamma=1;
bounds 0.0001 < gamma < 2, 0.0001 < alpha < 2;
weight = (nn_p1 ** gamma) /( ( (nn_p1 ** gamma) + (1-nn_p1) ** gamma) ** (1/gamma) );
value1 = nn_z1 ** alpha;
value2 = nn_z2 ** alpha;
z = (((weight * value1 + (1-weight) * value2) ** (1/alpha)) - &certain) / &certain;
run;
%mend nlptest;
/*HERE IS WHERE I START TO RUN INTO TROUBLE..... */
data array1;
set work.suregain; /* This data set contains the 96 variables I would like to loop through and pass into the macro for the nlp proc. */
array sure{*} _numeric_; /*I amk trying to create an array of the variables I need to pass to the macro */
input sure{*};
do i=1 to 96;
%nlptest(sure{i}); /*Macro will not accept this as a value*/
end;
Or
You might want to try call execute and the dictionary table, so you get the variable name as an argument.
data _null_; set sashelp.vcolumn(where=(libname='WORK' memname='SUREGAIN' xtype='num')); call execute('%nlptes('||strip(name)||')'); run;
Ksharp
You might want to try call execute and the vname function so you get the variable name as an argument.
Or
You might want to try call execute and the dictionary table, so you get the variable name as an argument.
data _null_; set sashelp.vcolumn(where=(libname='WORK' memname='SUREGAIN' xtype='num')); call execute('%nlptes('||strip(name)||')'); run;
Ksharp
Thank you for your help!
I really I appreciated it, I am feeling so lost trying to learn this stuff!!
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: