- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have a large set of random uniform distributed numbers between -6 and 10. My goal is to find the probability that the mean of my sample is between 2 and 3. I used the advice from a related post (https://communities.sas.com/t5/General-SAS-Programming/Random-numbers-Sample-size-then-calculate-mea...)
But I am still getting an error, Here is the code I am attempting:
data Prob1A;
call streaminit (0);
k= 2000;
n= 40000;
do i=1 to k;
xuni= rand('uniform', -6, 10);
output;
keep xuni;
end;
proc means data=Prob1A noprint;
by SampleID;
var xuni;
output out=1Ameans mean=SampleMean std=SampleStd;
run;
data p23;
set 1Ameans;
A1sol = (2< SampleMean < 3);
run;
proc freq data= p23;
tables A1sol;
run;
I'm not getting any output except for the error message: ERROR: Variable A1SOL not found. Why does my program not recognize this variable A1SOL? I thought it was adequately defined. Also I'm a bit stuck on how to proceed from here. I would like to be able to print the probability that the sample means are between 2 and 3. Thanks in advance!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for everyone's responses! After accumulating your collective advice, I have come up with a code that gives me what I need:
data Prob1A;
call streaminit (47);
k= 2000;
n= 40000;
do sampleid=1 to k;
do j=1 to n;
xuni= rand('uniform', -6, 10);
output;
end;
end;
keep sampleid xuni;
run;
proc means data=Prob1A noprint;
by SampleID;
var xuni;
output out=A1means mean=SampleMean std=SampleStd;
run;
data p197_24;
set A1means;
A1sol = (1.97< SampleMean < 2.4);
run;
proc freq data= p197_24;
tables A1sol;
run;
Thanks again!
Sorry the parameters are different than the original question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
because you proc means fails.
this by SampleID;
you have to have the by variable in the dataset being evaluated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What should I use instead of sampleID?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@valarievil you can use SampleID you just have to have it in the SAS dataset. So your first error in the process was at your proc means because the incoming dataset did not have SampleID in it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@valarievil wrote:
I have a large set of random uniform distributed numbers between -6 and 10. My goal is to find the probability that the mean of my sample is between 2 and 3. I used the advice from a related post (https://communities.sas.com/t5/General-SAS-Programming/Random-numbers-Sample-size-then-calculate-mea...)
But I am still getting an error, Here is the code I am attempting:
data Prob1A; call streaminit (0); k= 2000; n= 40000; do i=1 to k; xuni= rand('uniform', -6, 10); output; keep xuni; end; proc means data=Prob1A noprint; by SampleID; var xuni; output out=1Ameans mean=SampleMean std=SampleStd; run; data p23; set 1Ameans; A1sol = (2< SampleMean < 3); run; proc freq data= p23; tables A1sol; run;
I'm not getting any output except for the error message: ERROR: Variable A1SOL not found. Why does my program not recognize this variable A1SOL? I thought it was adequately defined. Also I'm a bit stuck on how to proceed from here. I would like to be able to print the probability that the sample means are between 2 and 3. Thanks in advance!
Surely there must be an earlier error in the LOG. Your PROC MEANS must have an error as well.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please slow down.
you need to get a SampleID variable in this process before you can continue.
proc means data=Prob1A noprint;
by SampleID;
var xuni;
output out=1Ameans mean=SampleMean std=SampleStd;
run;
data Prob1A;
call streaminit (0);
k= 2000;
n= 40000;
do i=1 to k;
xuni= rand('uniform', -6, 10);
output;
keep xuni;
end;
Where is the SampleID that proc means is doing the by on in Prob1A????
data Prob1A;
retain SampleID 0;
call streaminit (0);
k= 200;
n= 4000;
do b = 1 to 10;
do i=1 to k;
SampleID =b +1;
xuni= rand('uniform', -6, 10);
output;
keep xuni SampleID;
end;
end;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
you have a sas dataset that has a 1 at the begging.
remove the 1 from 1Ameans because that dataset is really Ameans when created by SAS
data p23;
set 1Ameans; A1sol = (2< SampleMean < 3);
run;
proc freq data= p23;
tables A1sol;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Will somebody please tell me why I keep getting the error "variable A1SOL not found"? What did I do wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
People have told you what you did wrong. You have errors earlier in the program, as PROC MEANS cannot work. I believe @VDD has pointed them out.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
then you have an incorrect SAS dataset name
calling it 1A can not happen SAS droped the 1 when it created the dataset here
proc means data=Prob1A noprint;
by SampleID;
var xuni;
output out=1Ameans mean=SampleMean std=SampleStd;
run;
And you need to do a proc sort on the incoming dataset if you use the by statement.
Did you @valarievil need to call the class SampleID or the by SampleID statement here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
please show complete log for ever datastep and proc somethings are issue prior to the final error. Start at the begging.
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for everyone's responses! After accumulating your collective advice, I have come up with a code that gives me what I need:
data Prob1A;
call streaminit (47);
k= 2000;
n= 40000;
do sampleid=1 to k;
do j=1 to n;
xuni= rand('uniform', -6, 10);
output;
end;
end;
keep sampleid xuni;
run;
proc means data=Prob1A noprint;
by SampleID;
var xuni;
output out=A1means mean=SampleMean std=SampleStd;
run;
data p197_24;
set A1means;
A1sol = (1.97< SampleMean < 2.4);
run;
proc freq data= p197_24;
tables A1sol;
run;
Thanks again!
Sorry the parameters are different than the original question.