BookmarkSubscribeRSS Feed
mary987
Calcite | Level 5

FOR THE FOLLWING DATA SET AS AN EXAMPLE 001 01/12/85 002 12/24/96 003 11/24/96 004 9/11/07 005 7/1/08 006 01/12/85 007 12/24/16 008 11/24/06 009 9/11/17 010 7/1/18 ; *CALCULATE YEARS UNTIL 31th of DEC 2020 THEN FIND FREQUENCY FOR:; * LESS THAN 5 YEARS; * BETWEEN 5 AND 10 YEARS; * 10 YEARS AND ABOVE;

 

I write this syntax but I receive error : no datalines or infile

DATA Example;
DOS="31DEC20"d;
NDAYS=INTCK("DAY",DOS,TODAY());
NWEEKS=INTCK("WEEK",DOS,TODAY());
MONTHS=MONTH(DOS);
YEAR=YEAR (DOS);
diff=yrdif (DOS,DOB);
input @1 ID $3.
@5 DOB mmddyy10.
datalines;
001 01/12/85
002 12/24/96
003 11/24/96
004 9/11/07
005 7/1/08
006 01/12/85
007 12/24/16
008 11/24/06
009 9/11/17
010 7/1/18
;

RUN;
PROC PRINT DATA=Example;
FORMAT DOS DATE9.;
RUN;

6 REPLIES 6
Rick_SAS
SAS Super FREQ

Put a semicolon at the end of the INPUT statement

input @1 ID $3. @5 DOB mmddyy10.;

mary987
Calcite | Level 5

tnx.

i want to find diff from 31DEC20 this date and the dates that are in datalines, I run this code for diff it shows period (.) for all observations.

Rick_SAS
SAS Super FREQ

Yes. The order of statements matter. Ask yourself what information has been read when you compute the DIFF variable. Are all the values that you need available at that time? Or perhaps you need to move that statement somewhere else in your program?  Good luck!

Rick_SAS
SAS Super FREQ

BTW, the period (.) means "missing value".  

mary987
Calcite | Level 5
yes, missing values. I do not put correct syntax for diff,
Kurt_Bremser
Super User

Apart from the order of variables in the YRDIF function (which will cause negative values), the assignment statement is OK, but its place in the code is not. You need to put it where the value for DOB has been read by the INPUT statement.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6 replies
  • 1200 views
  • 0 likes
  • 3 in conversation