turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- T Test for random distribution

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-17-2017 02:20 AM

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?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to kerowynmaria

12-17-2017 04:18 AM - edited 12-17-2017 04:20 AM

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;
```

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to kerowynmaria

12-17-2017 01:49 AM

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?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to kerowynmaria

12-17-2017 09:26 AM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to kerowynmaria

12-17-2017 09:37 AM

See my answer to your original post here

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to draycut

12-17-2017 02:29 PM

I merged the related threads.

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

How to convert datasets to data steps

How to post code

Maxims of Maximally Efficient SAS Programmers

How to convert datasets to data steps

How to post code

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to kerowynmaria

12-18-2017 05:43 PM

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 thenoutput 'E:\missleft';

if x > ub thenoutput '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.