*Question 1:===========*/
/*Use cards or datalines to read the following data into SAS. This
data set records the body weights of individuals at the beginning
of every month
over seven months for a weight-loss program. Please use one data
step to create a SAS data set that shows the number of months it
takes
for each individual to lose his/her first twenty pounds. Note that
no weight values from the original data set should be explicitly
referenced in the program.
John 238 223 214 199 195 188 180
Karen 183 175 176 168 163 155 148
Sam 165 168 172 166 155 148 142
*/
solution:
with data step we create dataset
with input statement we define variabes
with cards stattement we define data
There are two data types namely charater and numeric .
character datatype represented by $.
by default data type is numeric.
Ever program statemnt ends with semicolon.
sas program is
data have;
input name$ StartWT Month1 Month2 Month3 Month4 Month5
Month6;
cards;
John 238 223 214 199 195 188 180
Karen 183 175 176 168 163 155 148
Sam 165 168 172 166 155 148 142
;run;
Data want (keep=name Lbs_20_Lost_In);
set have;
array loss{6} month1-month6;
do i=1 to 6;
target=startwt-loss{i};
if target >= 20 then do;
Lbs_20_Lost_In=i;
output;
leave;
end;
end;
run;
Get Answers For Free
Most questions answered within 1 hours.