Please post your log? Also, please post an example of what your data looks like.
Makes it so much easier to help you
Reinhardt:
I was missing a then...if....then
and i got the following log:
Without having sample data this is a bit like detective work.
The missing values mentioned in the log can be explained as follows:
That's why you get (in "line 74" of the log):
This last fact in turn explains the 2138 missing values you obtain for variable PTRatio_rev in "line 76" (by dividing missing values by values of variable Teachers, many of which are most likely also missing, because only dataset TOTALTEACHERS can be reasonably expected to contain this variable according to your first data step).
So, merely concatenating the three datasets with the SET statement does not create a suitable basis for your calculations. Here is an instructive example of what happened in your program: Using the SET Statement When Data Sets Contain Different Variables.
If you need more help, please post a few lines of sample data (for each of the three datasets involved) in the form of a datastep (see instructions) and describe what you want as output.
"uninitialised" can be something as simple as a typo, for example you refer to variable "PTRatio" in a format statement but it is not defined anywhere, that would surely lead to "PTRatio is uninitialised" comment in the log. But you should specify which variable the log indicates is the problem
@savannah wrote:
I do not get any observations ...data totalstudentsgrd7togrd12;set impute_mid_schools impute_high_schools;if Teacher_mid>0 and Teacher_high>0;
Please note that the above subsetting IF statement will indeed block out all observations if Teacher_mid is a variable in impute_mid_schools (but not in impute_high_schools) and Teacher_high is a variable in impute_high_schools (but not in impute_mid_schools).
@savannah wrote:
... variables not initialized.
The number of uninitialized variables will decrease as soon as you delete the line where you seem to combine a RETAIN and a SET statement (but in fact create an uninitialized variable named SET among others) and correct the FORMAT statement to
format PTRatio_rev 9.2;
("Revised PTRatio" is probably the label of variable PTRatio_rev.)
Reinhardt:
I have included the code and the log. I modified as per your suggestion but it does not give me any obs as seen in the log. SInce i am dividing in the last step I wanted data without any zeros or miss val. all the 3 data sets have the values.
data totalteachers (keep = School County Teachers);
set impute_mid_schools impute_high_schools;
Total_Teachers=sum(of Teacher_mid Teacher_high);
Teachers =ceil(Total_Teachers);
run;
data totalstudentsgrd7togrd12;
set impute_mid_schools impute_high_schools totalteachers;
if Teacher_mid>0 and Teacher_high>0;
Total_Students_grd7togrd12=sum(of mid_Grd7-mid_Grd12)+sum(of hs_Grd7-hs_Grd12);
retain PTRatio_rev 0;
PTRatio_rev=Total_Students_grd7togrd12/Teachers;
format PTRatio_rev 9.2;
run;
log
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.