Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the SAS Commands for Q3, which includes analyte concentrations (BaBariu

ID: 3357135 • Letter: C

Question

Consider the SAS Commands for Q3, which includes analyte concentrations (BaBarium, Cu-Copper, Sb-Antimony, Pb-Lead) for a groundwater monitoring well. Concentrations below detection limit were listed as MDL (Below Minimum Detection Limit); any variable with MDL is initally read into GWWell as a character variable.

(a) Use ARRAY to change MDL to a “” (missing value for character variable) for variables Cu, Sb and Pb

(b) Add a statement to the ARRAY loop to convert the character variables Cu, Sb, and Pb to numeric variables

(c) Grad students. Suppose Ba (Barium) was recorded in parts per million (ppm). How would you print the follwoing label for Barium: ”Barium (ppm)”?

SAS Commands Q3

data GWWells;

input Year Period $ Ba Cu $ Sb $ Pb $;

datalines;

2011 Q1 33.4 MDL MDL MDL

2011 Q2 45.6 1.2 MDL MDL

2011 Q3 63.6 1.1 MDL .006

2011 Q4 36.3 1.5 MDL .007

2012 Q1 27.6 MDL MDL MDL

2012 Q2 26.5 1.1 MDL .009

2012 Q3 18.4 MDL MDL MDL

2012 Q4 40.3 MDL MDL .006

Explanation / Answer

a) In order to change values of cu, sb and pb, I have created a data one as follows:

data one;
set gwwells;
array chg{3} cu sb pb;
do count=1 to 3;
if chg{count} eq "MDL" then chg{count}="";
end;
drop count;
run;

b) To convert charecter variables to numeric using array:

data two;
set one;
array old{3} cu sb pb;
array new{3} cu1 sb1 pb1;
do i=1 to 3;
new{i}=input(old{i},5.1);
end;
drop cu sb pb i;
rename cu1=cu sb1=sb pb1=pb;
run;

c) To change variable label:

data three;
set two;
label ba="Barium (ppm)";
run;

To see the finalized data, we can use proc print:

proc print data=three;
run;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote