Help using Base SAS procedures

Multiple NLP....New to SAS

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Multiple NLP....New to SAS

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;


Accepted Solutions
Solution
‎07-19-2011 04:51 AM
Super User
Posts: 9,681

Re: Multiple NLP....New to SAS

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

View solution in original post


All Replies
Super User
Posts: 17,824

Multiple NLP....New to SAS

You might want to try call execute and the vname function so you get the variable name as an argument.

Solution
‎07-19-2011 04:51 AM
Super User
Posts: 9,681

Re: Multiple NLP....New to SAS

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

Occasional Contributor
Posts: 7

Multiple NLP....New to SAS

Thank you for your help!

I really I appreciated it, I am feeling so lost trying to learn this stuff!!

Smiley Happy

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 154 views
  • 3 likes
  • 3 in conversation