BookmarkSubscribeRSS Feed
Tom
Super User Tom
Super User

@sas_sad wrote:
data hiv1;
set hiv;
no_of_days = intck ('DAY',hivdiag_date,labdate);
run;

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):(Column).
      2603 at 60:14
NOTE: There were 2995385 observations read from the data set WORK.HIV.
NOTE: The data set WORK.HIV1 has 2995385 observations and 364 variables.
NOTE: DATA statement used (Total process time):
      real time           21.77 seconds
      cpu time            0.85 seconds


So you got it to work.

The note is saying that in 2,603 observations out of your 2,995,385 total observations one or more of your dates was missing.

sas_sad
Calcite | Level 5
No, but it does not give me difference in days between diagnosis date and lab test date.
Tom
Super User Tom
Super User

@sas_sad wrote:
No, but it does not give me difference in days between diagnosis date and lab test date.

How can you tell?   What do you get it you use PROC MEANS to look a the min/max/mean of your new calculated variable?

 

Look at your original dataset. How are those two "date" variables defined.

Since you didn't get any message about converting characters to number then the two variable are numeric.  But what types of values do they contain.  SAS stores dates as the number of days since 1960.  To make the number look readable to humans you need to attach for format like DATE or YYMMDD to the variable.

 

Some people create "date" variables that actual contain a datetime (or timestamp) value instead.  SAS stores those as the number of seconds since 1960.  If you want to calculate the number of days between two datetime values with INTCK() you need to use the DTDAY interval and not the DAY interval.  If one is DATE and the other is DATETIME then you need to convert one of them before comparing them.

 

Sometime people also create numeric variables with integer values like 20,210,721 and think those are date because they look like YYYYMMDD values when printed.

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 17 replies
  • 1837 views
  • 2 likes
  • 6 in conversation