DATA Step, Macro, Functions and more

Inserting variable array into loess procedure options

Reply
Occasional Contributor
Posts: 8

Inserting variable array into loess procedure options

Hi,

I am using the loess procedure to do some time series analysis, of the form:

proc loess data=table;

       model dependent=time / smooth= 0.1 0.2;

       ods output OutputStatistics=results;

  run;

I have a macro array of values I would like to use as the smoothing parameters, i.e. &sparam = {0.05 0.1 0.2 0.5}.

My question is: is it possible to insert the values of the array into the procedure under the smooth option? When I currently write "smooth = &sparam," I receive an unresolved symbol error. When I try to list out the names of all of the array elements using a %do-put loop, I receive an error that the smooth option expects a numeric value.

Any suggestions for how to approach this? I cannot simply write in the numeric values under smooth since I am looping through many times using different calculated values.

Thanks!

Lucy

Super User
Posts: 10,023

Re: Inserting variable array into loess procedure options

It is worked for me .

%let sparam = { 5 7 8 9 } ;

%let fix_sp=%sysfunc(compress(&sparam,{} ));

proc loess data=sashelp.buy;
       model amount=date / smooth= &fix_sp ;
       ods output OutputStatistics=results;

  run;

Ksharp

Occasional Contributor
Posts: 8

Re: Inserting variable array into loess procedure options

I did not end up using your method, but it is good to find out about the compress function.

Thanks!

Lucy

Ask a Question
Discussion stats
  • 2 replies
  • 177 views
  • 3 likes
  • 2 in conversation