BookmarkSubscribeRSS Feed
MisterJenn
Fluorite | Level 6

I am trying to create a temporary data set with smokers only (currentsmoker) in it. It says no observations so I know the code is not correct. 

 

libname hw3 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Week 3';
data fit1temp;
set hw3.fit2;
if upcase(compress(smoke)) = "CURRENTSMOKER" then currentsmoker = 1;
else if upcase(compress(smoke)) = "NONSMOKER" or 
upcase(compress(smoke)) = "FORMERSMOKER" then currentsmoker = 0;
if blvfx = "yes" or blnspfx = "yes" then any_base_frac = 1;
else if blvfx = "no" and blnspfx = "no" then any_base_frac = 0;
if newvfx = "yes" and newnspfx = "yes" then any_new_frac = 1; 
else if newvfx = "no" and newnspfx = "no" then any_new_frac = 0;
if bmi > 25 then bmi2 = "overweight"; 
else if 0 < bmi <= 25 then bmi2 = "normal";
if 0 < bmi <= 18 then bmi3 = "underweight";
else if 18 < bmi <= 25 then bmi3 = "normal"; 
else if bmi > 25 then bmi3 = "overweight";
bmi1_ind = (bmi > 25);
bmi2_ind = (18 < bmi <= 25);
bmi3_ind = (0 < bmi <= 18);
i_tx = (tx = "Alendronate");
diff_bmd = cobmd-blbmd;
age = (dov - dob)/365.25;
run; 
proc sgplot data=fit1temp;
vbox cobmd/group=tx; 
run;
proc means data=fit1temp mean median std p25 p75;
class tx;
var cobmd;
run;
proc ttest data=fit1temp;
class tx;
var cobmd;
run;
data fit1tmp_smoke;
set hw3.Fit2;
if CURRENTSMOKER = 1;
run;
proc sgplot data=fit1tmp_smoke;
vbox cobmd/group=tx; 
run;
120  libname hw3 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Week 3';
NOTE: Libref HW3 was successfully assigned as follows:
      Engine:        V9
      Physical Name: \\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Week 3
121  data fit1temp;
122  set hw3.fit2;
123  if upcase(compress(smoke)) = "CURRENTSMOKER" then currentsmoker = 1;
124  else if upcase(compress(smoke)) = "NONSMOKER" or
125  upcase(compress(smoke)) = "FORMERSMOKER" then currentsmoker = 0;
126  if blvfx = "yes" or blnspfx = "yes" then any_base_frac = 1;
127  else if blvfx = "no" and blnspfx = "no" then any_base_frac = 0;
128  if newvfx = "yes" and newnspfx = "yes" then any_new_frac = 1;
129  else if newvfx = "no" and newnspfx = "no" then any_new_frac = 0;
130  if bmi > 25 then bmi2 = "overweight";
131  else if 0 < bmi <= 25 then bmi2 = "normal";
132  if 0 < bmi <= 18 then bmi3 = "underweight";
133  else if 18 < bmi <= 25 then bmi3 = "normal";
134  else if bmi > 25 then bmi3 = "overweight";
135  bmi1_ind = (bmi > 25);
136  bmi2_ind = (18 < bmi <= 25);
137  bmi3_ind = (0 < bmi <= 18);
138  i_tx = (tx = "Alendronate");
139  diff_bmd = cobmd-blbmd;
140  age = (dov - dob)/365.25;
141  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      189 at 139:17
NOTE: There were 5580 observations read from the data set HW3.FIT2.
NOTE: The data set WORK.FIT1TEMP has 5580 observations and 22 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.01 seconds


142  proc sgplot data=fit1temp;
143  vbox cobmd/group=tx;
144  run;

NOTE: PROCEDURE SGPLOT used (Total process time):
      real time           0.17 seconds
      cpu time            0.07 seconds

NOTE: There were 5580 observations read from the data set WORK.FIT1TEMP.

145  proc means data=fit1temp mean median std p25 p75;
146  class tx;
147  var cobmd;
148  run;

NOTE: There were 5580 observations read from the data set WORK.FIT1TEMP.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


149  proc ttest data=fit1temp;
150  class tx;
151  var cobmd;
152  run;

NOTE: PROCEDURE TTEST used (Total process time):
      real time           1.25 seconds
      cpu time            0.76 seconds


153  data fit1tmp_smoke;
154  set hw3.Fit2;
155  if CURRENTSMOKER = 1;
156  run;

NOTE: Variable CURRENTSMOKER is uninitialized.
NOTE: There were 5580 observations read from the data set HW3.FIT2.
NOTE: The data set WORK.FIT1TMP_SMOKE has 0 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds


157  proc sgplot data=fit1tmp_smoke;
158  vbox cobmd/group=tx;
159  run;

NOTE: There were 0 observations read from the data set.
NOTE: PROCEDURE SGPLOT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


 

4 REPLIES 4
Kurt_Bremser
Super User
153  data fit1tmp_smoke;
154  set hw3.Fit2;
155  if CURRENTSMOKER = 1;
156  run;

NOTE: Variable CURRENTSMOKER is uninitialized.

There is no variable CURRENTSMOKER in your dataset hw3.fit2, so the test for it fails.

PaigeMiller
Diamond | Level 26
153  data fit1tmp_smoke;
154  set hw3.Fit2;
155  if CURRENTSMOKER = 1;
156  run;

NOTE: Variable CURRENTSMOKER is uninitialized.
NOTE: There were 5580 observations read from the data set HW3.FIT2.
NOTE: The data set WORK.FIT1TMP_SMOKE has 0 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds

 

There are zero observations in FIT1TMP_SMOKE, because you don't have a variable named CURRENTSMOKER in the data set HW3.FIT2, that's what the NOTE: is telling you, the variable is uninitialized. Since the variable doesn't exist, it is never equal to 1, and so no observations are sent to FIT1TMP_SMOKE.

--
Paige Miller
Reeza
Super User

The variable currentsmoker is created in the data set called fit1temp

The filter is applied to the input data set hw3.fit2 where the currentsmoker variable does not exist, therefore you get an error message of 

NOTE: Variable CURRENTSMOKER is uninitialized.

 

Ensure you're referencing the correct data set.

 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 580 views
  • 2 likes
  • 4 in conversation