SAS CODE

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,041
Accepted Solution

SAS CODE

Hi,

Could you help me figure out why I am getting this note??? after using the following lines of code???

  Also can I use the code like this????

  872 if Admission=0 and intck('year',Birth_Date2,ADMIT_DATE1) gt 1 then AgeAtAdmission=intck('year',Birth_Date2,ADMIT_DATE1);

  873 if intck('year',Birth_Date2,ADMIT_DATE1) lt 1 then AGEDAY=ADMIT_DATE1-Birth_Date2;

NOTE: Missing values were generated as a result of performing an operation on missing values.

Each place is given by: (Number of times) at (Line)Smiley SadColumn).

65 at 873:4    65 at 873:70

NOTE: There were 14178 observations read from the data set WORK.FINAL.

Thanks


Accepted Solutions
Solution
‎10-10-2014 05:03 AM
Occasional Contributor
Posts: 9

Re: SAS CODE

Posted in reply to robertrao

this is it :

data test;

informat Birth_Date2 Admit_date1 date9.;

format Birth_Date2 Admit_date1 date9.;

input Admission Birth_Date2 Admit_Date1;

var1 = intck('Year' , BirthDate2, Admit_Date1);

if Admission = 0 and var1 > 1 then AgeAtAdmission = var1;

else AgeDay = intck('day', BirthDate2,  Admit_date1);

drop var1;

cards;

1 15apr1980 .

0 15apr1980 20jun1985

0 10jul2000 22aug2010

0 15may2010 15jun2010

;

run:

View solution in original post


All Replies
Super User
Posts: 11,343

Re: SAS CODE

Posted in reply to robertrao

You have missing values for some of either Birth_Date2, Admit_Date1 or both. Run Proc Freq on those variables and see how many of each.

Super Contributor
Posts: 490

Re: SAS CODE

Posted in reply to robertrao

This note let you know about the missing values that were created.

for example check this 4. Missing values in assignment statements . It give you an example with details about this note.

PROC Star
Posts: 7,467

Re: SAS CODE

Posted in reply to robertrao

If you're only going to have an admit_date1 if someone has a value of 0 for admission then you have to account for that fact.

My question: why calculate two different variables for those above and below 1 year old when you could capture both with something like:

data have;

  informat Birth_Date2 ADMIT_DATE1 date9.;

  format Birth_Date2 ADMIT_DATE1 date9.;

  input Admission Birth_Date2 ADMIT_DATE1;

  if admission eq 0 then AgeAtAdmission=YRDIF(Birth_Date2,ADMIT_DATE1,'age');

  cards;

1 15apr1980 .

0 15apr1980 20jun1985

0 10jul2000 22aug2010

0 15may2010 15jun2010

;

Super Contributor
Posts: 1,041

Re: SAS CODE

Hi Art,

Thanks for the help.

The sas code requires the input file to have the new variable(ageday) created if age is less than an year.

I now understand that the "note" is because of some missing dates....

Is there any better way to recode the following.

872      if Admission=0 and intck('year',Birth_Date2,ADMIT_DATE1) gt 1 then AgeAtAdmission=intck     ('year',Birth_Date2,ADMIT_DATE1);

873 if intck('year',Birth_Date2,ADMIT_DATE1) lt 1 then AGEDAY=ADMIT_DATE1-Birth_Date2;

Thanks

Occasional Contributor
Posts: 9

Re: SAS CODE

Posted in reply to robertrao

You should put

intck('year',Birth_Date2,ADMIT_DATE1)

in a variable (so sas doesn't have to calculate 3 times the same thing + it reads better)

fe.

var1 = intck('year',Birth_Date2,ADMIT_DATE1);

if var1 > 1 then AgeAtAdmission = var1;

else  AgeDay = intck('day', ADMIT_DAT, Birth_Date2);

Super Contributor
Posts: 1,041

Re: SAS CODE

Posted in reply to BartDekeyser

Thanks Bart,

For helping me use the code efficiently.

I also wanted to know if the result would be the same both ways(with what u showed and what I have done prior)

Thanks

Solution
‎10-10-2014 05:03 AM
Occasional Contributor
Posts: 9

Re: SAS CODE

Posted in reply to robertrao

this is it :

data test;

informat Birth_Date2 Admit_date1 date9.;

format Birth_Date2 Admit_date1 date9.;

input Admission Birth_Date2 Admit_Date1;

var1 = intck('Year' , BirthDate2, Admit_Date1);

if Admission = 0 and var1 > 1 then AgeAtAdmission = var1;

else AgeDay = intck('day', BirthDate2,  Admit_date1);

drop var1;

cards;

1 15apr1980 .

0 15apr1980 20jun1985

0 10jul2000 22aug2010

0 15may2010 15jun2010

;

run:

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 280 views
  • 6 likes
  • 5 in conversation