Rsudio Problems
Rsudio Problems
12 #8
Purpose: To create a temporary data set of 1,000 observations with
random but equally likely integers from 1 to 5
Programmer: Ben Van Neste
Date Written: May 19th, 2021;
data WORK.INPUT;
do i=1 to 1000;
x=int(rand('uniform')*5)+1;output ;end;
run;
data Spirited;
set WORK.IMPORT;
where find(Customer,'spirit','i');
run;
data ThreeDates;
input @1 Date1 mmddyy10.
@12 Date2 mmddyy10.
@23 Date3 date9.;
format Date1 Date2 Date3 mmddyy10.;
datalines;
01/03/1950 01/03/1960 03Jan1970
05/15/2000 05/15/2002 15May2003
10/10/1998 11/12/2000 25Dec2005
;
run;
data ThreeDates;
set WORK.Import;
year12=round(yrdif(Date1,Date2,'Actual'));
year23=round(yrdif(Date2,Date3,'Actual'));
run;
Title "ThreeDates";
proc print data=threedates;
run;
data FormattedDates;
input Day Month Year;
datalines;
25 12 2005
1 1 1960
21 10 1946
run;
data FormattedDates;
set FormattedDates;
Date = mdy(Month,Day,Year);
format Date mmddyy10.;
run;
title "FormattedDates";
proc print data=FormattedDates;
run;
data Gym;
infile '/home/u58352038/my_shared_file_links/sue.mcdaniel/Wks
7&8/gym.txt' truncover;
input Subj : $3.
Date : mmddyy10.
Fee;
format Date mmddyy8. Fee Dollar6.;
run;
data Gym;
set Gym;
if _n_ = 1 then set MeanFee;
FeePercent = round(100*fee / AveFee);
drop AveFee;
run;
Data refile;
set work.import (keep = TotalSales Region);
Select;
when (Region = 'North') Weight = 1.5;
when (Region = 'South') Weight = 1.7;
when (Region = 'East') Weight = 2.0;
when (Region = 'West') Weight = 2.0;
otherwise;
end;
run;
Problem 7.10 #6
*Purpose: To specify North regions under 60 quantity and compare to
Pet’s are Us Customer
Problem 7.10 #6
Programmer: Ben Van Neste
Date Written: April 20th, 2021;
Data refile;
set work.import;
Problem 8.9 #4
*Purpose: To count the Missing Values in the Missing.txt data
Problem 8.9 #4
Programmer: Ben Van Neste
Date Written: April 26th, 2021;
data missing;
input A $ B $ C $;
if missing(A) then MissA + 1;
if missing(B) then MissB + 1;
if missing(C) then MissC + 1;
datalines;
1 2 3
4 5 .
6 7 8
9 10 11
;
run;
*Problem: 5.9 #2
Purpose: To see the frequencies of each question and also change to
just three categories
Programmer: Ben Van Neste
Date Written: April 12th, 2021;
data voter;
input Age $Party : $1. (Ques1-Ques4)($1. + 1);
datalines;
23 D 1 1 2 2
45 R 5 5 4 1
67 D 2 4 3 3
39 R 4 4 4 4
19 D 2 1 2 1
75 D 3 3 2 3
57 R 4 3 4 4
;
proc format;
value age low-30 = '0-30'
31-50 = '31-50'
51-70 = '51-71'
71-high = '71+';
value $party 'D' = 'Democrat'
'R' = 'Republican';
value $Ques 1,2 = "Generally Disagree"
3 = "No opinion"
4,5 = "Generally Agree";
title "Voter Questions";
proc print data=voter label;
label Ques1 = "The president is doing a good job"
Ques2 = "Congress is doing a good job"
Ques3 = "Taxes are too high"
Ques4 = "Government should cut spending";
format Age $Age.
Party $Party.
Ques1-Ques4 $Ques.;
run;
data colors;
input Color : $1. @@;
datalines;
R R B G Y Y . . B G R B G Y P O O V V B
;
proc format;
value $Color 'R','B','G' = 'Group 1'
'Y','O' = 'Group 2'
' ' = 'Not Given'
other = 'Group 3';
run;
Data InputOutput;
Infile"/home/u58352038/my_shared_file_links/sue.mcdaniel/Wks
1_2/mydata1.txt";
input Gender $ Age Height Weight;
*Compute the weight from pounds to kilos (WtKg);
WtKg = (Weight / 2.2);
run;
b)
*Purpose: The program converts heights from inches to centimeters
(HtCm)
Programmer: Ben Van Neste
Date Written: March 29, 2021;
Data InputOutput;
Infile"/home/u58352038/my_shared_file_links/sue.mcdaniel/Wks
1_2/mydata1.txt";
input Gender $ Age Height Weight;
*Compute the height from inches to centimeters (HtCm);
HtCm = (Height / 2.54);
run;
c)
I tried to find anything on how to calculate blood pressure with weight, height, and/or age but
could not come up on anything. Not knowing how else to approach this problem I included
code if the diastolic and systolic blood pressure was included in this data set..
*Purpose: The program converts weights from pounds to kilograms (WtKg)
Programmer: Ben Van Neste
Date Written: March 29, 2021;
Data InputOutput;
Infile"/home/u58352038/my_shared_file_links/sue.mcdaniel/Wks
1_2/mydata1.txt";
input Gender $ Age Height Weight;
*Compute the weight from pounds to kilos (WtKg);
WtKg = (Weight / 2.2);
run;
d)
*Purpose: The program calculates heights into polynomials
(HtPolynomial)
Programmer: Ben Van Neste
Date Written: March 29, 2021;
Data InputOutput;
Infile"/home/u58352038/my_shared_file_links/sue.mcdaniel/Wks
1_2/mydata1.txt";
input Gender $ Age Height Weight;
*Compute the height with polynomials (HtPolynomial);
HtPolynomial = ((Height**2)*2)+((Height**3)*1.5);
run;
C)
*Purpose: To create a temporary SAS data set from the political.csv
file.
Age is numerical, State and Party are character variables
Programmer: Ben Van Neste
Date Written: March 29, 2021;
data InputOutput;
Infile"/home/u58352038/my_shared_file_links/sue.mcdaniel/Wks
1_2/political.csv" dsd;
input State $ Party $ Age;
run;
title "Vote";
proc print data=InputOutput noobs;
run;
D)
*Purpose: To create a temporary SAS data set from the political.csv
file.
Age is numerical, State and Party are character variables
Programmer: Ben Van Neste
Date Written: March 29, 2021;
title "Vote";
proc print data=InputOutput noobs;
run;
E)
*Purpose: To create a SAS data set named Bank from the bankdata.txt
file.
Using column input for specification
Including a computed interest variable (Balance * Rate)
Programmer: Ben Van Neste
Date Written: March 29, 2021;
*FILENAME - nickname for filepath to BankData;
filename BankData
"/home/u58352038/my_shared_file_links/sue.mcdaniel/Wks
1_2/bankdata1.txt";
data InputOutput;
Infile BankData;
input Name $ 1-15
Account $ 16-20
Balance 21-26
Rate 27-30;
*Included varaible to compute Interest;
Interest = Balance*Rate;
run;
title "Bank";
proc print data=InputOutput noobs;
run;