BookmarkSubscribeRSS Feed
mjawla
Fluorite | Level 6

I am trying to group numeric data of two variables into categories of high and low, but I keep getting this Invalid numeric data error. How do I resolve it please.

Errors
Warnings (1)
Notes (44)


1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 data dhs.CRA1;
74 set dhs.CRA2;
75 if Triglyc <='199' then Triglyc='Low';
76 else Triglyc='High';
77 if HIV_RNA <='400' then HIV_RNA='Low';
78 else if '30000'>= HIV_RNA >='401' then HIV_RNA='High';
79 else HIV_RNA='Very_High';
80 run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
75:14 75:33 76:14 77:14 77:33 78:9 78:29 78:48 79:14
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'High' , at line 78 column 48.
LabSubNo=1 Date=07/08/2004 Week=2 HIV_RNA=. CD4=743 Triglyc=. Sex=male Race=Black HIVRiskF=IDU Randmizn=fAPV _ERROR_=1 _N_=1
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Very_High' , at line 79 column 14.
LabSubNo=1 Date=05/28/2004 Week=1 HIV_RNA=. CD4=724 Triglyc=. Sex=male Race=Black HIVRiskF=IDU Randmizn=fAPV _ERROR_=1 _N_=2
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Very_High' , at line 79 column 14.
LabSubNo=2 Date=06/01/2004 Week=2 HIV_RNA=. CD4=58 Triglyc=. Sex=male Race=Hispanic HIVRiskF=homosexual Randmizn=fAPV _ERROR_=1
_N_=3
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Low' , at line 77 column 33.
LabSubNo=2 Date=01/31/2005 Week=6 HIV_RNA=. CD4=323 Triglyc=. Sex=male Race=Hispanic HIVRiskF=homosexual Randmizn=fAPV _ERROR_=1
_N_=4
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Low' , at line 77 column 33.
LabSubNo=2 Date=11/01/2004 Week=5 HIV_RNA=. CD4=449 Triglyc=. Sex=male Race=Hispanic HIVRiskF=homosexual Randmizn=fAPV _ERROR_=1
_N_=5
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Low' , at line 77 column 33.
LabSubNo=2 Date=09/21/2004 Week=4 HIV_RNA=. CD4=294 Triglyc=. Sex=male Race=Hispanic HIVRiskF=homosexual Randmizn=fAPV _ERROR_=1
_N_=6
NOTE: Invalid numeric data, 'High' , at line 76 column 14.
NOTE: Invalid numeric data, 'Low' , at line 77 column 33.
LabSubNo=2 Date=07/06/2004 Week=3 HIV_RNA=. CD4=233 Triglyc=. Sex=male Race=Hispanic HIVRiskF=homosexual Randmizn=fAPV _ERROR_=1
_N_=7
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Low' , at line 77 column 33.
LabSubNo=2 Date=04/25/2005 Week=7 HIV_RNA=. CD4=494 Triglyc=. Sex=male Race=Hispanic HIVRiskF=homosexual Randmizn=fAPV _ERROR_=1
_N_=8
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Very_High' , at line 79 column 14.
LabSubNo=2 Date=05/10/2004 Week=1 HIV_RNA=. CD4=76 Triglyc=. Sex=male Race=Hispanic HIVRiskF=homosexual Randmizn=fAPV _ERROR_=1
_N_=9
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Very_High' , at line 79 column 14.
LabSubNo=3 Date=05/06/2004 Week=1 HIV_RNA=. CD4=40 Triglyc=. Sex=male Race=Black HIVRiskF=heterosexual Randmizn=fAPV _ERROR_=1
_N_=10
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Very_High' , at line 79 column 14.
LabSubNo=3 Date=05/26/2004 Week=2 HIV_RNA=. CD4=134 Triglyc=. Sex=male Race=Black HIVRiskF=heterosexual Randmizn=fAPV _ERROR_=1
_N_=11
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Low' , at line 77 column 33.
LabSubNo=3 Date=08/26/2004 Week=4 HIV_RNA=. CD4=190 Triglyc=. Sex=male Race=Black HIVRiskF=heterosexual Randmizn=fAPV _ERROR_=1
_N_=12
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Low' , at line 77 column 33.
LabSubNo=3 Date=11/18/2004 Week=5 HIV_RNA=. CD4=7.8000001907 Triglyc=. Sex=male Race=Black HIVRiskF=heterosexual Randmizn=fAPV
_ERROR_=1 _N_=13
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Low' , at line 77 column 33.
LabSubNo=3 Date=03/03/2005 Week=6 HIV_RNA=. CD4=167 Triglyc=. Sex=male Race=Black HIVRiskF=heterosexual Randmizn=fAPV _ERROR_=1
_N_=14
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Low' , at line 77 column 33.
LabSubNo=3 Date=07/01/2004 Week=3 HIV_RNA=. CD4=165 Triglyc=. Sex=male Race=Black HIVRiskF=heterosexual Randmizn=fAPV _ERROR_=1
_N_=15
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Low' , at line 77 column 33.
LabSubNo=3 Date=04/10/2005 Week=7 HIV_RNA=. CD4=. Triglyc=. Sex=male Race=Black HIVRiskF=heterosexual Randmizn=fAPV _ERROR_=1 _N_=16
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Very_High' , at line 79 column 14.
LabSubNo=3 Date=06/27/2005 Week=8 HIV_RNA=. CD4=40 Triglyc=. Sex=male Race=Black HIVRiskF=heterosexual Randmizn=fAPV _ERROR_=1
_N_=17
NOTE: Invalid numeric data, 'High' , at line 76 column 14.
NOTE: Invalid numeric data, 'High' , at line 78 column 48.
LabSubNo=3 Date=04/06/2006 Week=11 HIV_RNA=. CD4=189 Triglyc=. Sex=male Race=Black HIVRiskF=heterosexual Randmizn=fAPV _ERROR_=1
_N_=18
NOTE: Invalid numeric data, 'Low' , at line 75 column 33.
NOTE: Invalid numeric data, 'Low' , at line 77 column 33.
LabSubNo=3 Date=10/20/2005 Week=9 HIV_RNA=. CD4=193 Triglyc=. Sex=male Race=Black HIVRiskF=heterosexual Randmizn=fAPV _ERROR_=1
_N_=19
NOTE: Invalid numeric data, 'High' , at line 76 column 14.
NOTE: Invalid numeric data, 'Very_High' , at line 79 column 14.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
LabSubNo=3 Date=12/29/2005 Week=10 HIV_RNA=. CD4=76 Triglyc=. Sex=male Race=Black HIVRiskF=heterosexual Randmizn=fAPV _ERROR_=1
_N_=20
NOTE: There were 523 observations read from the data set DHS.CRA2.
NOTE: The data set DHS.CRA1 has 523 observations and 10 variables.
NOTE: DATA statement used (Total process time):
real time 0.11 seconds
cpu time 0.04 seconds


81
82 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
95

data dhs.CRA2;
set dhs.importcrd (keep=LabSubNo Race Randmizn Sex Triglyc Week HIV_RNA HIVRiskF Date CD4);
run;
/* arrange variables */
data dhs.CRA1;
set dhs.CRA2;
if Triglyc <='199' then Triglyc='Low';
else Triglyc='High';
if HIV_RNA <='400' then HIV_RNA='Low';
else if '30000'>= HIV_RNA >='401' then HIV_RNA='High';
else HIV_RNA='Very_High';
run;
3 REPLIES 3
Astounding
PROC Star
Your numbers shouldn't be in quotes, but that is a side issue.

HIV_RNA is a numeric variable. It can't hold 'Low' as its value. One fix is to assign a new variable the character version:

Length hiv_rnac $ 9;

Then assign values to hiv_rnac based on hiv_rna.
Satish_Parida
Lapis Lazuli | Level 10

Code Correction:

 

data dhs.CRA1(rename=(HIV_RNA1=HIV_RNA Triglyc1=Triglyc));
set dhs.CRA2;
if Triglyc <='199' then Triglyc1='Low';
else Triglyc1='High';
if HIV_RNA <='400' then HIV_RNA1='Low';
else if '30000'>= HIV_RNA >='401' then HIV_RNA1='High';
else HIV_RNA1='Very_High';
drop HIV_RNA Triglyc;
run;

Please let us know if it worked for you.

Kurt_Bremser
Super User

Since your variables are numeric, you need to create new obes to hold string values:

data dhs.CRA1;
set dhs.CRA2;
if Triglyc <= 199
then Triglyc_c = 'Low';
else Triglyc_c = 'High';
if HIV_RNA <= 400
then HIV_RNA_c = 'Low';
else if HIV_RNA <= 30000
then HIV_RNA_c = 'High';
else HIV_RNA_c = 'Very_High';
run;

or you create custom value formats with ranges and assign them to the numeric variables. SAS statistic procedures can work with formatted values.

sas-innovate-2024.png

📢

ANNOUNCEMENT

The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 719 views
  • 0 likes
  • 4 in conversation