So an example dataset is... Totsps. Totspm. Totspt 1. 1 8 2 5 5 2. 8 7 I’m looking to calculate the average of each row by creating a new variable avgslp 3
... View more
DATA SLEEP2;
infile ':\AH data.xlsx';
AVGSLP = MEAN(TOTSPSUN, TOTSPMON, TOTSPTUE, TOTSPWED);
RUN;
PROC MEANS DATA = WORK.PRAPCRO1;
AVGSP = MEAN(TOTSPSUN, TOTSPMON, TOTSPTUE, TOTSPWED);
VAR AVGSP;
RUN; how would i use a set statement?
... View more
I don’t get any output when I run the code to create a new variable. I want to create a new variable “avgsp” by calculating the meaning across 4 variables (totsps, totspm, totspt, totspw).... every time I try to run code in sas it says errors and the new data set has missing values. I think it may have something to do with me trying to use ‘infile’ to tell sas what data set to use.
... View more
Hello everyone- Thank you for your input. I am trying to get the average of 4 variables (totsps, totspm, totspt, totspw) and create a new variable called avgslp to get the average of the 4 days. I would like to do this for my entire data set. Thank you
... View more
I tried to do data want; infile 'data set'; input totsps totspm totspt totspw; avgsp = (totsps +totspm +totspt+totspw/4); run; but it creates a new variable but not a new output for avgsp. please help... i feel like my input step may be wrong
... View more
I am attempting to create a dummy variable for gender. Every time i run my code i get all zeros and i do not have an all male sample. data dummy4;
set dummy1;
if gen = 'male' then gen = 0;
if gen = 'female' then gen =1;
run;
data dummy1;
input id gen bedsun;
datalines;
2 Female 8100
3 Female 86400
4 . 84600
5 Female 82800
6 Female 84600
7 Female 82800
8 Female 82800
9 Male 84600
10 Male 84600
11 Male 81900
12 Male 84600
13 Male 12600
14 Male 85500
15 Female 2700
16 Female 7200
17 Female 81000
18 Female 79200
19 Female 86400
20 Female 83700
21 Female 5400
22 Female 78300
23 Female 86400
24 Male 84600
25 Male 900
26 Female 86400
27 Female 77400
28 Female 81000
29 Female 3600
30 Female 900
31 Female 83700
32 Female 86400
33 Female 75600
34 Female 85500
35 Female 81000
36 Male 3600
37 Female 3600
38 Female 74700
39 Female 85500
40 Male 82800
41 Female 18900
42 Female 86400
43 Female 3600
44 Female 81900
45 Female 10800
46 Male 84600
47 Female 83700
48 Male 84600
49 Male 85500
50 Male 8100
51 Female 83700
52 Female 82800
53 Female 5400
54 Female 3600
55 Female 77400
56 Female 9000
57 Female 84600
run;
... View more
Hi, I am fairly new to SAS 9.4 and I'm trying to format time that is equivalent to my times in the excel sheet. I imported the data and ran a proc print and it showed the times i wanted in 24 hour like i wanted but when i run a proc means to get the average time it displays a several digit number. I was wondering if someone could help me with coding this.
... View more