BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RobF
Quartz | Level 8

I'm creating a simple toy dataset containing date variables with the MMDDYY10. format:

data test;

input id $ ed_from MMDDYY10. ed_to MMDDYY10. ip_from MMDDYY10. ip_to MMDDYY10.;

format ed_from MMDDYY10. ed_to MMDDYY10. ip_from MMDDYY10. ip_to MMDDYY10.;

datalines;

CT0001 05/22/2011 05/22/2011 05/22/2011 05/30/2011

CT0001 06/22/2011 06/22/2011 06/22/2011 06/30/2011

CT0002 07/01/2012 07/02/2012 07/01/2012 07/06/2012

CT0002 07/10/2012 07/10/2012 07/20/2012 07/25/2012

;

run;

However I receive "Invalid data..." error messages when I attempt to run the above code.

Any help identifying what I'm doing wrong is much appreciated!

Thanks,

Robert

1 ACCEPTED SOLUTION

Accepted Solutions
DBailey
Lapis Lazuli | Level 10

try this:

input id $ ed_from:MMDDYY10. ed_to:MMDDYY10. ip_from:MMDDYY10. ip_to:MMDDYY10.;

View solution in original post

4 REPLIES 4
DBailey
Lapis Lazuli | Level 10

try this:

input id $ ed_from:MMDDYY10. ed_to:MMDDYY10. ip_from:MMDDYY10. ip_to:MMDDYY10.;

RobF
Quartz | Level 8

Fantastic, worked beautifully. I wasn't aware we should use colons in the input statement, this is good to know.

Thanks DBailey!

PGStats
Opal | Level 21

You can use either formatted input with a field size that correspond with the TOTAL column spacing:

input id $ (ed_from ed_to ip_from ip_to) (MMDDYY11.);

or use pointer controls to move the line pointer to the beginning of date fields:

input id $ (ed_from ed_to ip_from ip_to) (+1 MMDDYY10.);

or modified list input with an informat that correspond with the size of the text tokens irrespective of the spacing between them:

input id $ (ed_from ed_to ip_from ip_to) (:MMDDYY10.);

PG

Message was edited by: PG Added an alternative.

PG
RobF
Quartz | Level 8

Thank you, this is very helpful!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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