dofor looping and smpl in stats

For questions and discussion related to reading in and working with data.
fan
Posts: 215
Joined: Wed Jun 19, 2013 5:14 pm

dofor looping and smpl in stats

Unread post by fan »

Hi Tom,

I would like to know how I can use

Code: Select all

dofor 
and

Code: Select all

smpl 
together. I tried

Code: Select all

dofor i = x1 x2 x3; stats(smpl=i) y; enddofor i 
but it did not work. It only gives result for i = x1. Do I need to use special instructions here? Many Thanks
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: dofor looping and smpl in stats

Unread post by TomDoan »

fan wrote:Hi Tom,

I would like to know how I can use

Code: Select all

dofor 
and

Code: Select all

smpl 
together. I tried

Code: Select all

dofor i = x1 x2 x3; stats(smpl=i) y; enddofor i 
but it did not work. It only gives result for i = x1. Do I need to use special instructions here? Many Thanks
Use

stats(smpl=i{0}) y

The right side of SMPL (and some other options such as WEIGHT and SPREAD) is a formula, so you need I{0} to make sure it's evaluated as an element of a series.
fan
Posts: 215
Joined: Wed Jun 19, 2013 5:14 pm

Re: dofor looping and smpl in stats

Unread post by fan »

TomDoan wrote:
fan wrote:Hi Tom,

I would like to know how I can use

Code: Select all

dofor 
and

Code: Select all

smpl 
together. I tried

Code: Select all

dofor i = x1 x2 x3; stats(smpl=i) y; enddofor i 
but it did not work. It only gives result for i = x1. Do I need to use special instructions here? Many Thanks
Use

stats(smpl=i{0}) y

The right side of SMPL (and some other options such as WEIGHT and SPREAD) is a formula, so you need I{0} to make sure it's evaluated as an element of a series.
Thank you for the quick reply
Post Reply