BookmarkSubscribeRSS Feed
kerowynmaria
Calcite | Level 5

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?

6 REPLIES 6
kerowynmaria
Calcite | Level 5

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?

WarrenKuhfeld
Rhodochrosite | Level 12

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.

PeterClemmensen
Tourmaline | Level 20

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;

 

ballardw
Super User

@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.

 

 

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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