New Contributor
Posts: 2

# T Test for random distribution

I have a sample t distribution and for my sample I have to figure out confidence intervals along with their upper and loew bounds. I figured out the formula to determine the upper and lower bounds but when I do an if then to see what from my sample is a miss it tells me :ERROR 455-185: Data set was not specified on the DATA statement.

my code looks like :

%let n=20;*this is the size of each sample;
%let sims=10;*this is for the outer loop that says how many times the simulation is repeated;
%let df=6;*parameters needed;
%let t=1.94; *t value for a ttest with a df of 6;
data confidence(keep=missright missleft);
set sample;
lb=xbar-(t*(std/(sqrt(n))));
ub=xbar+(t*(std/(sqrt(n))));
if x < lb then output 'E:\missleft';
if x > ub then output 'E:\missright';
miss='E:\missright'+'E:\missleft';
output;
end;
proc print; run;

for the missleft and missright is where i see the problem. How do I fix this?

PROC Star
Posts: 1,410

## Re: T Test for random distribution

[ Edited ]

There are a few things here..

1) What does your sample data set look like?

2) You initialize 4 macro variables at the top of your program but does not use them anywhere? Remember that when you want to reference the macro variable n, type &n.. Also, you do not use your df or sims macro variable anywhere?

3) You have not specified the missright and missleft data sets in your data step. Thus you can not write to them like that. And therefore you get the error. I don't think you should output to several data sets when your x variable is not inside the confidence interval. Simply make another variable that indicates where the x value falls.

Without having seen your sample data set, I think your code should look something like this (given that xbar and x are both variables in your sample data set)

``````%let n=20;
%let t=1.94;

data confidence;
set sample;
missleft=0;
missright=0;

lb=xbar-(&t*(std/(sqrt(&n))));
ub=xbar+(&t*(std/(sqrt(&n))));
if x < lb then missleft=1;
if x > ub then missright=1;
end;

proc print data=confidence;
run;``````

New Contributor
Posts: 2

## Statistical Computing

I have a sample t distribution and for my sample I have to figure out confidence intervals along with their upper and loew bounds. I figured out the formula to determine the upper and lower bounds but when I do an if then to see what from my sample is a miss it tells me :ERROR 455-185: Data set was not specified on the DATA statement.

my code looks like :

%let n=20;*this is the size of each sample;
%let sims=10;*this is for the outer loop that says how many times the simulation is repeated;
%let df=6;*parameters needed;
%let t=1.94; *t value for a ttest with a df of 6;
data confidence(keep=missright missleft);
set sample;
lb=xbar-(t*(std/(sqrt(n))));
ub=xbar+(t*(std/(sqrt(n))));
if x < lb then output 'E:\missleft';
if x > ub then output 'E:\missright';
miss='E:\missright'+'E:\missleft';
output;
end;
proc print; run;

for the missleft and missright is where i see the problem. How do I fix this?

SAS Super FREQ
Posts: 508

## Re: Statistical Computing

When you say OUTPUT with a name, it needs to be a SAS data set name.

data a b;

....

output a;

....

output b;

run;

Start by figuring out how many data sets you want to make.  Probably one.  Get rid of all of the E: file references. It looks like you are mixing up variable names and files.

PROC Star
Posts: 1,410

Super User
Posts: 10,623

## Re: Statistical Computing

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 13,950

## Re: T Test for random distribution

kerowynmaria wrote:

I have a sample t distribution and for my sample I have to figure out confidence intervals along with their upper and loew bounds. I figured out the formula to determine the upper and lower bounds but when I do an if then to see what from my sample is a miss it tells me :ERROR 455-185: Data set was not specified on the DATA statement.

my code looks like :

%let n=20;*this is the size of each sample;
%let sims=10;*this is for the outer loop that says how many times the simulation is repeated;
%let df=6;*parameters needed;
%let t=1.94; *t value for a ttest with a df of 6;
data confidence(keep=missright missleft);
set sample;
lb=xbar-(t*(std/(sqrt(n))));
ub=xbar+(t*(std/(sqrt(n))));
if x < lb then output 'E:\missleft';
if x > ub then output 'E:\missright';
miss='E:\missright'+'E:\missleft';
output;
end;
proc print; run;

for the missleft and missright is where i see the problem. How do I fix this?

The syntax highlighted in red is not legal. OUTPUT requires a data set specified on the DATA statement. The OUTPUT statement send values to a dataset.

Data  missleft missright;

if x< lb then output missleft;

if x> ub then output missright;

If you want to create a numeric variable it would be something like

missleft = <some numeric operation>; from what I see that might be something like

if x<lb then missleft=x;

if x> ub then missright=x;

miss='E:\missright'+'E:\missleft';

Addition with text elements (things between quotes) is not allowed in SAS. Addition would require the creation of numeric variables.

I don't understand why you want to add rissright and missleft, one would likely be missing for every record and both could be missing for the majority of records.

Discussion stats
• 6 replies
• 222 views
• 0 likes
• 5 in conversation