Hi I am trying to split a table into three tables with only one DATA step but what I am doing is not working. When I am outputting rows to these tables I need to create a variable called diet_type to display either Diet One Diet Two or Diet Three. This is my code for this entire dataset but I think the most relevant code is after the second data step. options VALIDVARNAME=V7;
proc import datafile="/home/u54324957/The Files/Diet.csv" out=Diet
dbms=csv
replace;
data dietfile;
set Diet;
First_Name=PROPCASE(First_Name);
Last_Name=PROPCASE(Last_Name);
FullName=strip(Last_Name) || "," || strip(First_Name);
Length SexVariable $ 6;
if Sex=0 then
SexVariable="Male";
else if Sex=1 then
SexVariable="Female";
drop Sex;
rename SexVariable=Sex;
diet_num=input(substr(diet, 6, 1), 1.);
pre_weightlbs=pre_weight * 2.205;
format pre_weightlbs 5.1;
post_weightlbs=weight10weeks * 2.205;
format post_weightlbs 5.1;
weightloss=pre_weight - weight10weeks;
format weightloss 4.1;
drop Last_Name First_Name pre_weight Diet weight10weeks;
/* The most relevant code is below */
data Diet1 Diet2 Diet3;
set Diet;
if diet_num = 1 then do;
diet_num = 1;
output Diet1;
end;
else if diet_num=2 then do;
diet_num = 2;
output Diet2;
end;
else do;
diet_num = 3;
output Diet3;
end; For some reason only Diet3 has any observations according to the Log. diet_num is a numeric variable Copy and paste this to get the data i.stack.imgur.com/8gVka.png. I think the only relevant column is diet_num. Any ideas?
... View more