05-10-2024
kcvaldez98
Obsidian | Level 7
Member since
10-06-2023
- 29 Posts
- 6 Likes Given
- 1 Solutions
- 4 Likes Received
-
Latest posts by kcvaldez98
Subject Views Posted 1890 05-09-2024 05:21 PM 2823 02-28-2024 10:41 AM 2840 02-28-2024 10:28 AM 1149 12-07-2023 01:30 PM 1164 12-07-2023 01:20 PM 1661 12-07-2023 12:36 PM 1678 12-07-2023 12:28 PM 1181 12-07-2023 12:23 PM 1709 12-07-2023 12:01 PM 1209 12-07-2023 11:50 AM -
Activity Feed for kcvaldez98
- Posted Missing Observations on New SAS User. 05-09-2024 05:21 PM
- Liked Re: WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed. for SASJedi. 02-29-2024 09:22 AM
- Posted Re: WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed. on New SAS User. 02-28-2024 10:41 AM
- Posted WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed. on New SAS User. 02-28-2024 10:28 AM
- Got a Like for Re: MACRO Using CALL SYNTAX. 12-07-2023 01:50 PM
- Posted Re: Linear Regression Change Variable Name in Fit Plot on New SAS User. 12-07-2023 01:30 PM
- Posted Re: Linear Regression Change Variable Name in Fit Plot on New SAS User. 12-07-2023 01:20 PM
- Liked Re: Boxplot Help for antonbcristina. 12-07-2023 12:47 PM
- Liked Re: Boxplot Help for ballardw. 12-07-2023 12:47 PM
- Posted Re: MACRO Using CALL SYNTAX on New SAS User. 12-07-2023 12:36 PM
- Posted Re: MACRO Using CALL SYNTAX on New SAS User. 12-07-2023 12:28 PM
- Posted Re: Linear Regression Change Variable Name in Fit Plot on New SAS User. 12-07-2023 12:23 PM
- Posted MACRO Using CALL SYNTAX on New SAS User. 12-07-2023 12:01 PM
- Posted Linear Regression Change Variable Name in Fit Plot on New SAS User. 12-07-2023 11:50 AM
- Posted Boxplot Help on New SAS User. 12-07-2023 11:46 AM
- Posted Re: ODS RTF File on New SAS User. 12-07-2023 10:42 AM
- Posted Re: ODS RTF File on New SAS User. 12-06-2023 11:32 AM
- Posted ODS RTF File on New SAS User. 12-06-2023 11:18 AM
- Posted Using Label as Variable Name in a Linear Regression on New SAS User. 12-04-2023 12:28 PM
- Got a Like for Re: PROC ANOVA. 11-29-2023 04:53 PM
-
Posts I Liked
Subject Likes Author Latest Post 1 1 1 1 1 -
My Liked Posts
Subject Likes Posted 2 12-07-2023 12:36 PM 2 11-29-2023 03:52 PM
05-09-2024
05:21 PM
Hi SAS Coders:
I am trying to change numeric observations into character so I can do my analysis, but it is showing blank observations for these variables:
Obs
fast
purge
language
age_group
sex_category
ethnicity
USBorn
slimfast
DescribeWt
HomeEnv
1
.
.
E
<11
Male
NonH
Life
No
VeryOver
PrettyT
2
.
.
E
<11
Male
NonH
Life
No
SlghtOve
VeryTru
3
.
.
E
<11
Male
Hisp
Miss
Mis
Right
Missing
4
.
.
E
<11
Female
NonH
Life
No
Right
VeryTru
5
.
.
E
<11
Male
Hisp
Life
No
SltUnder
PrettyT
6
.
.
E
<11
Female
Hisp
Life
No
Right
VeryTru
7
.
.
E
<11
Female
NonH
Life
No
Right
PrettyT
8
.
.
E
<11
Female
NonH
Life
No
SlghtOve
PrettyT
9
.
.
E
<11
Female
NonH
Life
No
SltUnder
VeryTru
10
.
.
E
<11
Female
NonH
Life
No
Right
VeryTru
I know the observations are in fact numeric as it says "1" and "2" in the dataset
My code is this:
DATA WORK.CLEANDATA;
SET YRRSIMPT.import;
/* Categorize age */
IF age < 11 THEN age_group = "<11";
ELSE IF age = 12 THEN age_group = "12";
ELSE IF age = 13 THEN age_group = "13";
ELSE IF age = 14 THEN age_group = "14";
ELSE IF age >= 15 THEN age_group = "14+";
ELSE age_group = "Missing";
/* Categorize sex */
IF sex = 1 THEN sex_category = "Female";
ELSE IF sex = 2 THEN sex_category = "Male";
ELSE sex_category = "Missing";
IF v4 = 1 THEN ethnicity = "Hisp";
ELSE IF v4 = 2 THEN ethnicity = "NonHisp";
ELSE ethnicity = "Missing";
/* Categorize v66 (USBorn) */
IF v66 = 1 THEN USBorn = "<1Yr";
ELSE IF v66 = 2 THEN USBorn = "1-3Yrs";
ELSE IF v66 = 3 THEN USBorn = "4-6Yrs";
ELSE IF v66 = 4 THEN USBorn = "6+Yr";
ELSE IF v66 = 5 THEN USBorn = "Life";
ELSE USBorn = "Missing";
/* Categorize v51 */
IF v51 = 1 THEN fast = "Yes";
ELSE IF v51 = 2 THEN fast = "No";
ELSE fast = "Missing";
/* Categorize v52 */
IF v52 = 1 THEN purge = "Yes";
ELSE IF v52 = 2 THEN purge = "No";
ELSE purge = "Missing";
/* Categorize v53 */
IF v53 = 1 THEN slimfast = "Yes";
ELSE IF v53 = 2 THEN slimfast = "No";
ELSE slimfast = "Missing";
IF v49 = 1 THEN DescribeWt = "VUnderWt";
ELSE IF v49 = 2 THEN DescribeWt = "SltUnder";
ELSE IF v49 = 3 THEN DescribeWt = "Right";
ELSE IF v49 = 4 THEN DescribeWt = "SlghtOver";
ELSE IF v49 = 5 THEN DescribeWt = "VeryOver";
ELSE DescribeWt = "Missing";
/* Categorize v71 (HomeEnv) */
IF v71 = 1 THEN HomeEnv = "NotTrue";
ELSE IF v71 = 2 THEN HomeEnv = "LilTrue";
ELSE IF v71 = 3 THEN HomeEnv = "PrettyTrue";
ELSE IF v71 = 4 THEN HomeEnv = "VeryTrue";
ELSE HomeEnv = "Missing";
KEEP age_group ethnicity sex_category HomeEnv purge fast USBorn DescribeWt language slimfast;
RUN;
... View more
Labels:
02-28-2024
10:41 AM
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 DATA LAB.STUDY_COHORT_2;
70 FORMAT race_eth $30.;
71 SET LAB.STUDY_COHORT;
72
73 /* Gestational diabetes */
74 IF RFDiabGest = "True" THEN GestDiab= "Y";
75 ELSE GestDiab= "N";
76
77 /* Race/Ethnicity variable */
78 IF MatRace = " " OR MatEthnicity = " " THEN race_eth=" ";
79 ELSE IF SUBSTR(MatEthnicity,1,1) = "2" THEN race_eth="Hispanic (any race)";
80 ELSE IF SUBSTR(MatRace,2,1)="1" THEN race_eth = "Non-Hispanic White";
81 ELSE race_eth="Non-Hispanic Non-White";
82
83 /* Previous live births need to be converted to numeric variable */
84 prev_alive2 = INPUT(PREV_ALIVE, 2.);
85 IF PREV_ALIVE= . THEN PREV_ALIVE = .;
86
87 /* Convert mother's height to height in inches */
88 IF MotherHeight= . THEN Ht_inches = .;
89 ELSE Ht_inches=(INPUT(SUBSTR(MotherHeight,2,1),1.)*12)+(INPUT(SUBSTR(MotherHeight,4,2),2.));
90
91 /* Convert prior weight to a numeric variable */
92 IF priorweight = . THEN priorweight2 = .; /* Set to missing if unknown */
93 ELSE priorweight2= INPUT(priorweight,4.);
94
95 /* Calculate BMI */
96 IF priorweight2= . or Ht_inches= . THEN BMI = .; /* Set to missing if height or weight is missing */
97 ELSE BMI = ((priorweight2)/(Ht_inches**2))*703;
98
99 /* Categorize into Obese status */
100 IF BMI = . THEN ObesePrior = " "; /* Set to missing if BMI is missing */
101 ELSE IF BMI < 30 THEN ObesePrior = "N";
102 ELSE ObesePrior = "Y";
103
104 /* Variable for preterm birth */
105 IF EstGest > 36 THEN Preterm = "N";
106 ELSE Preterm = "Y";
107
108 /* Labeling new variables */
109 LABEL GestDiab = "Gestational Diabetes"
110 race_eth = "Race/Ethnicity"
111 prev_alive2 = "Previous Live Births"
112 Ht_inches = "Mother's Height (in inches)"
113 priorweight2 = "Prior Weight Before Pregnancy"
114 BMI = "Body Mass Index"
115 ObesePrior = "Obese Prior (Y/N)"
116 Preterm = "Gestation Age Before 37 Weeks";
117 RUN;
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
85:7 88:8 92:8 105:8
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
85:39
NOTE: Invalid numeric data, MotherHeight='05:07' , at line 88 column 8.
race_eth=Hispanic (any race) ID=2012000176 MotherHeight=05:07 PriorWeight=170 PREV_ALIVE=2 RFDiabGest= EstGest=39 EstGestOb=
EstGestClin=True Plurality=1 MatEthnicity=210 MatRace=01 M_AGE=31 GestDiab=N prev_alive2=2 Ht_inches=. priorweight2=170 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=1
NOTE: Invalid numeric data, MotherHeight='05:02' , at line 88 column 8.
race_eth=Hispanic (any race) ID=2012000324 MotherHeight=05:02 PriorWeight=220 PREV_ALIVE=1 RFDiabGest=True EstGest=38 EstGestOb=True
EstGestClin= Plurality=1 MatEthnicity=280 MatRace=01 M_AGE=32 GestDiab=Y prev_alive2=1 Ht_inches=. priorweight2=220 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=2
NOTE: Invalid numeric data, MotherHeight='05:01' , at line 88 column 8.
race_eth=Hispanic (any race) ID=2012000510 MotherHeight=05:01 PriorWeight=123 PREV_ALIVE=0 RFDiabGest= EstGest=39 EstGestOb=True
EstGestClin= Plurality=1 MatEthnicity=210 MatRace=01 M_AGE=20 GestDiab=N prev_alive2=0 Ht_inches=. priorweight2=123 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=3
NOTE: Invalid numeric data, MotherHeight='05:02' , at line 88 column 8.
race_eth=Hispanic (any race) ID=2012001165 MotherHeight=05:02 PriorWeight=145 PREV_ALIVE=0 RFDiabGest= EstGest=38 EstGestOb=
EstGestClin=True Plurality=1 MatEthnicity=210 MatRace=01 M_AGE=22 GestDiab=N prev_alive2=0 Ht_inches=. priorweight2=145 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=4
NOTE: Invalid numeric data, MotherHeight='05:04' , at line 88 column 8.
race_eth=Non-Hispanic White ID=2012001472 MotherHeight=05:04 PriorWeight=194 PREV_ALIVE=3 RFDiabGest= EstGest=39 EstGestOb=
EstGestClin=True Plurality=1 MatEthnicity=100 MatRace=01 M_AGE=35 GestDiab=N prev_alive2=3 Ht_inches=. priorweight2=194 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=5
NOTE: Invalid numeric data, MotherHeight='05:07' , at line 88 column 8.
race_eth=Non-Hispanic White ID=2012001710 MotherHeight=05:07 PriorWeight=123 PREV_ALIVE=0 RFDiabGest= EstGest=41 EstGestOb=True
EstGestClin= Plurality=1 MatEthnicity=100 MatRace=01 M_AGE=30 GestDiab=N prev_alive2=0 Ht_inches=. priorweight2=123 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=6
NOTE: Invalid numeric data, MotherHeight='05:04' , at line 88 column 8.
race_eth=Non-Hispanic White ID=2012001836 MotherHeight=05:04 PriorWeight=132 PREV_ALIVE=0 RFDiabGest= EstGest=40 EstGestOb=True
EstGestClin= Plurality=1 MatEthnicity=100 MatRace=01 M_AGE=30 GestDiab=N prev_alive2=0 Ht_inches=. priorweight2=132 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=7
NOTE: Invalid numeric data, MotherHeight='05:03' , at line 88 column 8.
race_eth=Non-Hispanic White ID=2012001863 MotherHeight=05:03 PriorWeight=149 PREV_ALIVE=1 RFDiabGest= EstGest=40 EstGestOb=
EstGestClin=True Plurality=1 MatEthnicity=100 MatRace=01 M_AGE=30 GestDiab=N prev_alive2=1 Ht_inches=. priorweight2=149 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=8
NOTE: Invalid numeric data, MotherHeight='04:08' , at line 88 column 8.
race_eth=Hispanic (any race) ID=2012002184 MotherHeight=04:08 PriorWeight=128 PREV_ALIVE=0 RFDiabGest= EstGest=41 EstGestOb=True
EstGestClin= Plurality=1 MatEthnicity=210 MatRace=01 M_AGE=23 GestDiab=N prev_alive2=0 Ht_inches=. priorweight2=128 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=9
NOTE: Invalid numeric data, MotherHeight='05:00' , at line 88 column 8.
race_eth=Hispanic (any race) ID=2012002326 MotherHeight=05:00 PriorWeight=160 PREV_ALIVE=0 RFDiabGest= EstGest=37 EstGestOb=True
EstGestClin= Plurality=1 MatEthnicity=281 MatRace=01 M_AGE=20 GestDiab=N prev_alive2=0 Ht_inches=. priorweight2=160 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=10
NOTE: Invalid numeric data, MotherHeight='04:11' , at line 88 column 8.
race_eth=Hispanic (any race) ID=2012002393 MotherHeight=04:11 PriorWeight=122 PREV_ALIVE=8 RFDiabGest= EstGest=38 EstGestOb=True
EstGestClin= Plurality=1 MatEthnicity=210 MatRace=01 M_AGE=38 GestDiab=N prev_alive2=8 Ht_inches=. priorweight2=122 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=11
NOTE: Invalid numeric data, MotherHeight='04:11' , at line 88 column 8.
race_eth=Hispanic (any race) ID=2012002548 MotherHeight=04:11 PriorWeight=143 PREV_ALIVE=1 RFDiabGest= EstGest=37 EstGestOb=True
EstGestClin= Plurality=1 MatEthnicity=210 MatRace=01 M_AGE=28 GestDiab=N prev_alive2=1 Ht_inches=. priorweight2=143 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=12
NOTE: Invalid numeric data, MotherHeight='05:02' , at line 88 column 8.
race_eth=Hispanic (any race) ID=2012003049 MotherHeight=05:02 PriorWeight=125 PREV_ALIVE=1 RFDiabGest= EstGest=41 EstGestOb=
EstGestClin=True Plurality=1 MatEthnicity=210 MatRace=01 M_AGE=20 GestDiab=N prev_alive2=1 Ht_inches=. priorweight2=125 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=13
NOTE: Invalid numeric data, MotherHeight='04:11' , at line 88 column 8.
race_eth=Non-Hispanic White ID=2012003074 MotherHeight=04:11 PriorWeight=195 PREV_ALIVE=1 RFDiabGest= EstGest=35 EstGestOb=True
EstGestClin= Plurality=1 MatEthnicity=100 MatRace=01 M_AGE=28 GestDiab=N prev_alive2=1 Ht_inches=. priorweight2=195 BMI=.
ObesePrior= Preterm=Y _ERROR_=1 _N_=14
NOTE: Invalid numeric data, MotherHeight='05:04' , at line 88 column 8.
race_eth=Hispanic (any race) ID=2012003126 MotherHeight=05:04 PriorWeight=160 PREV_ALIVE=1 RFDiabGest= EstGest=40 EstGestOb=
EstGestClin=True Plurality=1 MatEthnicity=210 MatRace=01 M_AGE=23 GestDiab=N prev_alive2=1 Ht_inches=. priorweight2=160 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=15
NOTE: Invalid numeric data, MotherHeight='05:06' , at line 88 column 8.
race_eth=Non-Hispanic White ID=2012003186 MotherHeight=05:06 PriorWeight=130 PREV_ALIVE=0 RFDiabGest= EstGest=39 EstGestOb=
EstGestClin=True Plurality=1 MatEthnicity=100 MatRace=01 M_AGE=30 GestDiab=N prev_alive2=0 Ht_inches=. priorweight2=130 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=16
NOTE: Invalid numeric data, MotherHeight='05:07' , at line 88 column 8.
race_eth=Non-Hispanic White ID=2012003306 MotherHeight=05:07 PriorWeight=137 PREV_ALIVE=0 RFDiabGest= EstGest=37 EstGestOb=True
EstGestClin= Plurality=1 MatEthnicity=100 MatRace=01 M_AGE=21 GestDiab=N prev_alive2=0 Ht_inches=. priorweight2=137 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=17
NOTE: Invalid numeric data, MotherHeight='05:01' , at line 88 column 8.
race_eth=Hispanic (any race) ID=2012003437 MotherHeight=05:01 PriorWeight=130 PREV_ALIVE=0 RFDiabGest= EstGest=39 EstGestOb=
EstGestClin=True Plurality=1 MatEthnicity=281 MatRace=01 M_AGE=16 GestDiab=N prev_alive2=0 Ht_inches=. priorweight2=130 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=18
NOTE: Invalid numeric data, MotherHeight='05:02' , at line 88 column 8.
NOTE: Invalid numeric data, PriorWeight='?' , at line 92 column 8.
race_eth=Non-Hispanic Non-White ID=2012003508 MotherHeight=05:02 PriorWeight=? PREV_ALIVE=3 RFDiabGest= EstGest=39 EstGestOb=
EstGestClin=True Plurality=1 MatEthnicity=100 MatRace=10 M_AGE=24 GestDiab=N prev_alive2=3 Ht_inches=. priorweight2=. BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=19
NOTE: Invalid numeric data, MotherHeight='05:01' , at line 88 column 8.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
race_eth=Non-Hispanic White ID=2012003665 MotherHeight=05:01 PriorWeight=180 PREV_ALIVE=1 RFDiabGest= EstGest=40 EstGestOb=
EstGestClin=True Plurality=1 MatEthnicity=100 MatRace=01 M_AGE=23 GestDiab=N prev_alive2=1 Ht_inches=. priorweight2=180 BMI=.
ObesePrior= Preterm=N _ERROR_=1 _N_=20
NOTE: There were 292 observations read from the data set LAB.STUDY_COHORT.
NOTE: The data set LAB.STUDY_COHORT_2 has 292 observations and 20 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.01 seconds
memory 1009.37k
OS Memory 23464.00k
Timestamp 02/28/2024 03:40:49 PM
Step Count 34 Switch Count 2
Page Faults 0
Page Reclaims 173
Page Swaps 0
Voluntary Context Switches 44
Involuntary Context Switches 0
Block Input Operations 32
Block Output Operations 280
118
119 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
129
... View more
02-28-2024
10:28 AM
Hi SAS users!
I am doing some SAS homework and ran into this warning which won't let me convert character into numeric and therefore I am unable to run half this code. My goal is for prev_alive2 to be numeric and Ht_Inches to be numeric so I can calculate the BMI so I can have the BMI to look at mothers who are obese prior to pregnancy. Let me show you my code: and please let me know where I went wrong.
DATA LAB.STUDY_COHORT_2;
FORMAT race_eth $30.;
SET LAB.STUDY_COHORT;
/* Gestational diabetes */
IF RFDiabGest = "True" THEN GestDiab= "Y";
ELSE GestDiab= "N";
/* Race/Ethnicity variable */
IF MatRace = " " OR MatEthnicity = " " THEN race_eth=" ";
ELSE IF SUBSTR(MatEthnicity,1,1) = "2" THEN race_eth="Hispanic (any race)";
ELSE IF SUBSTR(MatRace,2,1)="1" THEN race_eth = "Non-Hispanic White";
ELSE race_eth="Non-Hispanic Non-White";
/* Previous live births need to be converted to numeric variable */
prev_alive2 = INPUT(PREV_ALIVE, 2.);
IF PREV_ALIVE= . THEN PREV_ALIVE = .;
/* Convert mother's height to height in inches */
IF MotherHeight= . THEN Ht_inches = .;
ELSE Ht_inches=(INPUT(SUBSTR(MotherHeight,2,1),1.)*12)+(INPUT(SUBSTR(MotherHeight,4,2),2.));
/* Convert prior weight to a numeric variable */
IF priorweight = . THEN priorweight2 = .; /* Set to missing if unknown */
ELSE priorweight2= INPUT(priorweight,4.);
/* Calculate BMI */
IF priorweight2= . or Ht_inches= . THEN BMI = .; /* Set to missing if height or weight is missing */
ELSE BMI = ((priorweight2)/(Ht_inches**2))*703;
/* Categorize into Obese status */
IF BMI = . THEN ObesePrior = " "; /* Set to missing if BMI is missing */
ELSE IF BMI < 30 THEN ObesePrior = "N";
ELSE ObesePrior = "Y";
/* Variable for preterm birth */
IF EstGest > 36 THEN Preterm = "N";
ELSE Preterm = "Y";
/* Labeling new variables */
LABEL GestDiab = "Gestational Diabetes"
race_eth = "Race/Ethnicity"
prev_alive2 = "Previous Live Births"
Ht_inches = "Mother's Height (in inches)"
priorweight2 = "Prior Weight Before Pregnancy"
BMI = "Body Mass Index"
ObesePrior = "Obese Prior (Y/N)"
Preterm = "Gestation Age Before 37 Weeks";
RUN;
The dataset looks like this:
Obs
ID
MotherHeight
PriorWeight
PREV_ALIVE
RFDiabGest
EstGest
EstGestOb
EstGestClin
Plurality
MatEthnicity
MatRace
M_AGE
1
2012000176
05:07
170
2
39
True
1
210
01
31
2
2012000324
05:02
220
1
True
38
True
1
280
01
32
3
2012000510
05:01
123
0
39
True
1
210
01
20
4
2012001165
05:02
145
0
38
True
1
210
01
22
5
2012001472
05:04
194
3
39
True
1
100
01
35
6
2012001710
05:07
123
0
41
True
1
100
01
30
7
2012001836
05:04
132
0
40
True
1
100
01
30
8
2012001863
05:03
149
1
40
True
1
100
01
30
9
2012002184
04:08
128
0
41
True
1
210
01
23
10
2012002326
05:00
160
0
37
True
1
281
01
20
11
2012002393
04:11
122
8
38
True
1
210
01
38
12
2012002548
04:11
143
1
37
True
1
210
01
28
13
2012003049
05:02
125
1
41
True
1
210
01
20
14
2012003074
04:11
195
1
35
True
1
100
01
28
15
2012003126
05:04
160
1
40
True
1
210
01
23
16
2012003186
05:06
130
0
39
True
1
100
01
30
17
2012003306
05:07
137
0
37
True
1
100
01
21
18
2012003437
05:01
130
0
39
True
1
281
01
16
19
2012003508
05:02
?
3
39
True
1
100
10
24
20
2012003665
05:01
180
1
40
True
1
100
01
23
21
2012003987
05:06
178
0
39
True
1
100
01
31
22
2012004002
05:03
154
0
True
36
True
1
100
01
27
23
2012004481
04:07
131
0
40
True
1
210
01
36
24
2012004529
05:09
175
1
39
True
1
100
01
31
25
2012004620
05:08
219
2
39
True
1
210
15
22
26
2012004670
05:06
190
1
39
True
1
100
01
34
27
2012004797
05:04
145
1
40
True
1
210
01
22
28
2012005112
05:04
174
2
39
True
1
210
01
30
29
2012005419
05:05
141
0
40
True
1
100
01
29
30
2012005472
05:03
120
0
38
True
1
100
01
27
31
2012005558
05:08
261
1
39
True
1
100
01
29
32
2012005704
05:04
?
2
40
True
1
210
01
27
... View more
Labels:
12-07-2023
01:30 PM
PROC REG DATA=WORK.FIGURE (RENAME=outcomes_adults_mental_distr='Frequent Mental Distress'n)
PLOTS(ONLY) = FITPLOT;
LABEL Marijuana_Use = 'Percent of People Who Used Marijuana 1+ Days out of 30 Days';
'Linear Regression'n:
MODEL 'Frequent Mental Distress'n = Marijuana_Use /
CLM
CLI
ALPHA=0.05;
TITLE "Linear Regression of Frequent Mental Distress and Marijuana Use";
ODS SELECT FitPlot;
RUN;
... View more
12-07-2023
01:20 PM
I figured it out, thank you
... View more
12-07-2023
12:36 PM
2 Likes
This makes a lot more sense now, yes I was using ODS OUTPUT to create that particular dataset and I named the datasets TABLEONE TABLETWO AND TABLETHREE as part of the work library because I wanted to not confuse myself, but I guess I confused SAS communities. so that table that I presented has 4 observations so only the last one will be presented when I run that code you provided?
That's interesting and I appreciate the explanation because now it's becoming clear to me what I need to do. I may be overthinking how to get the end result but that is extremely helpful!
... View more
12-07-2023
12:28 PM
Yes, here is my code to get that table that I presented:
ODS TRACE ON;
PROC GLM DATA=ANOVA;
CLASS Quartiles;
MODEL riskfactors_quartiles = Marijuana_Use Education_Status Poverty_Percent Frequent_Mental_Dist;
RUN;
QUIT;
ODS TRACE OFF;
ODS OUTPUT ModelANOVA=TableTwo;
PROC GLM DATA=ANOVA;
CLASS Quartiles;
MODEL riskfactors_quartiles = Marijuana_Use Education_Status Poverty_Percent Frequent_Mental_Dist;
RUN;
QUIT;
Then I cleaned up the table and merged it with my first table which has the means and standard deviations that was presented, but I mostly used ODS OUTPUT to manipulate my tables so it has the p value.
... View more
12-07-2023
12:23 PM
My code is:
OPTIONS VALIDVARNAME=ANY;
PROC REG DATA=WORK.FIGURE (RENAME = outcomes_adults_mental_distr = Frequent_Mental_Distress)
PLOTS(ONLY) = FITPLOT;
LABEL Marijuana_Use = 'Percent of People Who Used Marijuana 1+ Days out of 30 Days';
'Linear Regression'n:
MODEL Frequent_Mental_Distress = Marijuana_Use /
CLM
CLI
ALPHA=0.05;
TITLE "Linear Regression of Frequent Mental Distress and Marijuana Use";
ODS SELECT FitPlot;
RUN;
TITLE;
Thank you so much! I thought there was only like two procedures but good to know that there are more!
... View more
12-07-2023
12:01 PM
Hello!
Let me see if I can explain this well. I am working on a project in my SAS class and my professor wants us to create a macro that extracts p values from our tables and use that macro to basically put in our rtf file this code:
ods rtf text="Insert here an interpretation of your parameter estimates with your macro variable";
She wants us to create the macro using call syntax and it has to just be inserted into that rtf text that I provided. My p values are in a dataset called WORK.TABLETWO and it is the p values I got from using PROC GLM and using an ANOVA test.
Here is my table two for reference:
So I guess my professor wants the p value column to be extracted using a MACRO variable using CALL SYNTAX to use in a RTF TEXT to be inserted into our RTF File.
I hope that makes sense, any advice would be helpful on how to do any of this since I am very new to macros
... View more
12-07-2023
11:50 AM
Hi Sas coders!
I create a linear regression that looks like this:
I am trying to change the Frequent_Mental_Distress in the Fit plot title to say: Fit Plot for Frequent Mental Distress without any of the underscores, I tried doing IF THEN statements and renaming statements but I don't know if I can use labels to be displayed in the fit plot title. Is that possible? My label would be "Percent of people with Frequent Mental Distress"
Thank you!
... View more
12-07-2023
11:46 AM
Hi SAS Coders!
I created a box plot that looks like this:
My quartiles are out of order and I have tried everything. Here is my code for reference:
ODS NOPROCTITLE;
PROC SGPLOT DATA=WORK.FIGURE;
VBOX outcomes_adults_mental_distr /
GROUPORDER = DATA
CATEGORY=Quartiles
FILLATTRS=(COLOR=LIGHTBLUE) BOXWIDTH=0.8;
TITLE BOLD "Boxplot of Quartiles of Marijuana Use and Frequent Mental Distress";
XAXIS DISPLAY=(NOLABEL) LABELATTRS=(WEIGHT=BOLD);
YAXIS LABEL="Frequent Mental Distress" VALUES=(0 TO 100 BY 10) OFFSETMIN=0;
XAXIS LABEL="Quartiles";
REFLINE 70 / AXIS=Y LINEATTRS=(COLOR=BLUE);
REFLINE 90 / AXIS=Y LINEATTRS=(COLOR=BLUE);
YAXIS GRID;
INSET "Data Source: Colorado Study Data"/ POSITION=NW BORDER;
RUN;
How do I get it where it goes from "First Quartile, Second Quartile, Third Quartile and Fourth Quartile" ?
Please advise
... View more
12-07-2023
10:42 AM
Thank you everyone, it appears that it is working again.
Thank you for all the solutions!
... View more
12-06-2023
11:32 AM
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
NOTE: ODS statements in the SAS Studio environment may disable some output features.
69
70 ODS RTF FILE = "/home/u63558208/Project One/CDPHE Data/5_Results/FinalProject.rtf"
71 STYLE=BARRETTSBLUE;
NOTE: Writing RTF Body file: /home/u63558208/Project One/CDPHE Data/5_Results/FinalProject.rtf
72
73
74 TITLE1'Means and Standard Deviations of Demographics, Risk Factors, and Outcomes';
75 PROC PRINT DATA=COLANLYS.TABLEONE LABEL NOOBS;
76 RUN;
NOTE: There were 4 observations read from the data set COLANLYS.TABLEONE.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 1568.40k
OS Memory 27812.00k
Timestamp 12/06/2023 04:15:29 PM
Step Count 533 Switch Count 0
Page Faults 0
Page Reclaims 88
Page Swaps 0
Voluntary Context Switches 5
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
77 TITLE;
78
79
80 TITLE1'ANOVA of Demographics, Risk Factors, and Outcomes';
81 PROC PRINT DATA = COLANLYS.TABLETWO LABEL NOOBS;
82 RUN;
NOTE: There were 4 observations read from the data set COLANLYS.TABLETWO.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 766.15k
OS Memory 27812.00k
Timestamp 12/06/2023 04:15:29 PM
Step Count 534 Switch Count 0
Page Faults 0
Page Reclaims 64
Page Swaps 0
Voluntary Context Switches 4
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
83 TITLE;
84 FOOTNOTE "p-values > .05";
85 FOOTNOTE;
86
87
88 TITLE1"Pearson's Correlation Between Demographics, Risk Factors, and the Outcome";
89 PROC PRINT DATA=COLANLYS.TABLETHREE LABEL NOOBS;
90 RUN;
NOTE: There were 4 observations read from the data set COLANLYS.TABLETHREE.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 687.53k
OS Memory 27812.00k
Timestamp 12/06/2023 04:15:29 PM
Step Count 535 Switch Count 0
Page Faults 0
Page Reclaims 71
Page Swaps 0
Voluntary Context Switches 4
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
91 TITLE;
92
93 ODS GRAPHICS ON;
94 ODS NOPROCTITLE;
95 PROC SGPLOT DATA=WORK.FIGURE;
96 VBOX outcomes_adults_mental_distr / CATEGORY=Quartiles FILLATTRS=(COLOR=LIGHTBLUE) BOXWIDTH=0.5;
97 TITLE BOLD "Boxplot of Quartiles of Marijuana Use and Frequent Mental Distress";
98 XAXIS LABEL="Quartiles of Marijuana Use" VALUEATTRS=(WEIGHT=BOLD);
99 YAXIS LABEL="Frequent Mental Distress" VALUES=(0 TO 100 BY 10) OFFSETMIN=0;
100 REFLINE 70 / AXIS=Y LINEATTRS=(COLOR=BLUE);
101 REFLINE 90 / AXIS=Y LINEATTRS=(COLOR=BLUE) LABEL="HYPERTENSION THRESHOLD" LABELPOS=max;
102 YAXIS GRID;
103 INSET "Data Source: Colorado Study Data"/ POSITION=NW BORDER;
104 RUN;
NOTE: PROCEDURE SGPLOT used (Total process time):
real time 0.13 seconds
user cpu time 0.06 seconds
system cpu time 0.02 seconds
memory 15736.25k
OS Memory 40616.00k
Timestamp 12/06/2023 04:15:29 PM
Step Count 536 Switch Count 2
Page Faults 0
Page Reclaims 3677
Page Swaps 0
Voluntary Context Switches 466
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 768
NOTE: There were 64 observations read from the data set WORK.FIGURE.
105 TITLE;
106
107
108 ODS NOPROCTITLE;
109 OPTIONS VALIDVARNAME=ANY;
110 PROC REG DATA=WORK.FIGURE (RENAME = outcomes_adults_mental_distr = Frequent_Mental_Distress)
111 PLOTS(ONLY) = FITPLOT;
112 LABEL Marijuana_Use = 'Percent of People Who Used Marijuana 1+ Days out of 30 Days';
113 'Linear Regression'n:
114 MODEL Frequent_Mental_Distress = Marijuana_Use /
115 CLM
116 CLI
117 ALPHA=0.05;
118
119 TITLE "Linear Regression of Frequent Mental Distress and Marijuana Use";
120 ODS SELECT FitPlot;
121 RUN;
122 TITLE;
123
124 ODS GRAPHICS OFF;
125 ODS RTF CLOSE;
126
127 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
... View more
12-06-2023
11:18 AM
Hello, SAS coders.
I am creating an ODS RTF File and it shows up like this
But my code is this:
ODS RTF FILE = "/home/u63558208/Project One/CDPHE Data/5_Results/FinalProject.rtf" STYLE=BARRETTSBLUE;
TITLE1'Means and Standard Deviations of Demographics, Risk Factors, and Outcomes'; PROC PRINT DATA=COLANLYS.TABLEONE LABEL NOOBS; RUN; TITLE;
TITLE1'ANOVA of Demographics, Risk Factors, and Outcomes'; PROC PRINT DATA = COLANLYS.TABLETWO LABEL NOOBS; RUN; TITLE; FOOTNOTE "p-values > .05"; FOOTNOTE;
TITLE1"Pearson's Correlation Between Demographics, Risk Factors, and the Outcome"; PROC PRINT DATA=COLANLYS.TABLETHREE LABEL NOOBS; RUN; TITLE;
ODS GRAPHICS ON; ODS NOPROCTITLE; PROC SGPLOT DATA=WORK.FIGURE; VBOX outcomes_adults_mental_distr / CATEGORY=Quartiles FILLATTRS=(COLOR=LIGHTBLUE) BOXWIDTH=0.5; TITLE BOLD "Boxplot of Quartiles of Marijuana Use and Frequent Mental Distress"; XAXIS LABEL="Quartiles of Marijuana Use" VALUEATTRS=(WEIGHT=BOLD); YAXIS LABEL="Frequent Mental Distress" VALUES=(0 TO 100 BY 10) OFFSETMIN=0; REFLINE 70 / AXIS=Y LINEATTRS=(COLOR=BLUE); REFLINE 90 / AXIS=Y LINEATTRS=(COLOR=BLUE) LABEL="HYPERTENSION THRESHOLD" LABELPOS=max; YAXIS GRID; INSET "Data Source: Colorado Study Data"/ POSITION=NW BORDER; RUN; TITLE;
ODS NOPROCTITLE; OPTIONS VALIDVARNAME=ANY; PROC REG DATA=WORK.FIGURE (RENAME = outcomes_adults_mental_distr = Frequent_Mental_Distress) PLOTS(ONLY) = FITPLOT; LABEL Marijuana_Use = 'Percent of People Who Used Marijuana 1+ Days out of 30 Days'; 'Linear Regression'n: MODEL Frequent_Mental_Distress = Marijuana_Use / CLM CLI ALPHA=0.05;
TITLE "Linear Regression of Frequent Mental Distress and Marijuana Use"; ODS SELECT FitPlot; RUN; TITLE;
ODS GRAPHICS OFF; ODS RTF CLOSE;
Is there something I did wrong? I am confused it was working before but now it looks like that.
... View more
12-04-2023
12:28 PM
Hi SAS coders,
I am new to SAS and was wondering if it is possible to use labels as the variable names for a PROC REG?
Here's my code:
ODS NOPROCTITLE; PROC REG DATA=WORK.FIGURE (RENAME = outcomes_adults_mental_distr = Frequent_Mental_Distress) PLOTS(ONLY) = FITPLOT; MODEL Frequent_Mental_Distress = Marijuana_Use / CLM CLI ALPHA=0.05;
TITLE "Linear Regression of Frequent Mental Distress and Marijuana Use"; ODS SELECT FitPlot; RUN; TITLE;
The output looks like this:
I want it to show that Marijuana_Use and Frequent_Mental_Distress is displayed as their labels and I also was wondering if I can delete the "Model: MODEL1" out?
Any help is appreciated.
Thank you!
... View more