BookmarkSubscribeRSS Feed
hudasaeb
Calcite | Level 5

Issue with If then subsetting statement with data with both numerical and character values. No error is showing but note is  NOTE: Invalid numeric data, '30-35 months' , at line 75 column 13. The output table is showing no values at all. 

data nis_age;
set nis_use;
if AGEGRP = "30-35 months" then output;
run;

Help please. 

3 REPLIES 3
Astounding
PROC Star

When you examine the variable AGEGRP, you will find that it is a numeric variable.  There is no way it could possibly hold the characters "30-35 months".  You may need to fix the data first.

ballardw
Super User

@hudasaeb wrote:

Issue with If then subsetting statement with data with both numerical and character values. No error is showing but note is  NOTE: Invalid numeric data, '30-35 months' , at line 75 column 13. The output table is showing no values at all. 

data nis_age;
set nis_use;
if AGEGRP = "30-35 months" then output;
run;

Help please. 


As @Astounding says, AGEGRP is numeric. If the values of Agegrp are integers you could use in with the range operator:

 

if AGEGRP in (30:35) then output;

or alternatively

if 30 le agegrp le 35 then output;

 

le is "less than or equal" to include the end values.

art297
Opal | Level 21

My guess is that your dataset has formatted values. If that is the case, then you could use the vvalue function. i.e.,

 

data nis_age;
  set nis_use;
  if vvalue(AGE_GROUP) eq '30-35 months';
run;

Art, CEO, AnalystFinder.com

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 996 views
  • 3 likes
  • 4 in conversation