BookmarkSubscribeRSS Feed
PrinceAde
Obsidian | Level 7

data ex2;
set ex1;
first_id = first.usubjid;
last_id = last.usubjid;
*line 256;if first_id ne 0 then TRTSDT=input(EXSTDTC, yymmdd10.);
*line 257;if last_id = 1 then TRTEDT=input(EXENDTC, yymmdd10.);
format TRTSDT TRTEDT date9.;
run;

LOG;

NOTE: Invalid argument to function INPUT at line 257 column 28.
USUBJID=CYT001302-3901-12855 ACTARM=CYT001 10 MG EXSTDTC=2008-10-10 EXENDTC=2012-01 FIRST_ID=1
LAST_ID=1 ACTARMCD=CYT0 TRT01A=CYT001 10 MG TRTSDT=10OCT2008 TRTEDT=. _ERROR_=1 _N_=269
NOTE: Invalid argument to function INPUT at line 257 column 28

 

Line 256 works just fine. Please what could be the problem in line 257?

Please kindly help to resolve this error

4 REPLIES 4
PaigeMiller
Diamond | Level 26
USUBJID=CYT001302-3901-12855 ACTARM=CYT001 10 MG EXSTDTC=2008-10-10 EXENDTC=2012-01 FIRST_ID=1
LAST_ID=1 ACTARMCD=CYT0 TRT01A=CYT001 10 MG TRTSDT=10OCT2008 TRTEDT=. _ERROR_=1 _N_=269

 

You cannot read the value 2012-01 with the informat yymmdd10.

 

See Maxim 3: Know Your Data

--
Paige Miller
PrinceAde
Obsidian | Level 7

Ok.  I just realized that some record in EXSTDTC has partial dates like (2012/01, 2009. Majority of the data are complete. Thank you sir.

ballardw
Super User

@PrinceAde wrote:

Ok.  I just realized that some record in EXSTDTC has partial dates like (2012/01, 2009. Majority of the data are complete. Thank you sir.


If these are pretty consistent patterns as to the value you could test the length of the EXSTDTC variable and conditionally use different input calls. This approach will impute values for day of month or day and month based on provided values.

data example;
  input Exendtc :$10.;
  last_id =1;

   if last_id =1 then select (length(Exendtc));
      when (8,9,10) TRTEDT=input(EXENDTC, yymmdd10.);
      when (7)      TRTEDT=input(catx('/',EXENDTC,'01'), yymmdd10.);
      when (6)      TRTEDT=input(EXENDTC, yymmn6.);
      when (4)      TRTEDT=input(cats(EXENDTC,'01'), yymmn6.);
      otherwise ;
   end;
   format TRTEDT date9.;
datalines;
20201115
2020/11/15
2020/07
202003
2020
;

If you want to impute a different day of the month or month replace the '01' with the day or month preferred. Note that the YYMMN informat will impute the day of the month to be 1.

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
  • 4 replies
  • 534 views
  • 0 likes
  • 4 in conversation