Choose Language Hide Translation Bar
Highlighted
tsj
tsj
Level I

Using variable for control chart sample size

I am trying to use a variable for a control chart sample size and it won't accept it. The following code works:
Samples=6;
tempchart=Control Chart(
Sample Label( :DateTime ),
Sample Size( 4) ,
KSigma( 3 ),
Chart Col( :Value, XBar, R ),save summaries);

but these do not:
Samples=6;
tempchart=Control Chart(
Sample Label( :DateTime ),
Sample Size( Samples) ,
KSigma( 3 ),
Chart Col( :Value, XBar, R ),save summaries);

Samples=6;
tempchart=Control Chart(
Sample Label( :DateTime ),
Sample Size( 4*6) ,
KSigma( 3 ),
Chart Col( :Value, XBar, R ),save summaries);

I have also tried sample size (eval(Samples)), but it doesn't work either.

Any ideas?
2 REPLIES 2
Highlighted
XanGregg
Staff

Using variable for control chart sample size

I think this is a case where only literals are accepted. See my answer to

http://communities.sas.com/thread/30007?tstart=0

for a work-around.

Highlighted
tsj
tsj
Level I

Re: Using variable for control chart sample size

Thanks for the post.  I am still having problems with this.  It looks like it is working correctly, but then the output is wrong.  If I run the following script:

XBar_R_BL = 4;

TempChartExp=substitute(expr(Control Chart(

  Sample Label( :DateTime ),

  Sample Size( SAMPLESIZESUB1) ,

  KSigma( 3 ),

  Chart Col( :Value, XBar, R ),save summaries)),expr(SAMPLESIZESUB1),XBar_R_BL);

show(TempChartExp);

TempChart1 = eval (TempChartExp);

The show statement gives the following:

     TempChartExp = Control Chart(Sample Label(:DateTime), Sample Size(4), KSigma(3), Chart Col(:Value, XBar, R), save summaries);

Which is exactly what I wanted.  However, when the eval statement is executed, I get a data table with 1 row and a chart with one point.  If I copy the script from the chart, I get:

Control Chart( Sample Label( :c000004 ), KSigma( 3 ), Chart Col( :Value, XBar, R ) )

So it has changed the column for the sample label and it has dropped the sample size al together.  Any help is appreciated.

Article Labels

    There are no labels assigned to this post.