BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10
/*I was presente a file with the similar structure*/
data have;
informat "Completion Date"N mmddyy10. ;
format "Completion Date"N mmddyy10. ;
input
"Completion Date"N;
run;

here is the output
1/11/2016 01:50 PM America/New York
NOTE: Invalid data for 'Completion Date'n


i believe I get this invalid message due to the Completion Date not actually
being a format mmddyy10. It has some text in it

Is there a way to reconfigure the informat or format to account for the
desired mmddyy10 date and the timezone that accompanies this???

5 REPLIES 5
SASKiwi
PROC Star

Please post an example of your input data and the SAS log from your program run.

ballardw
Super User

@Q1983 wrote:
/*I was presente a file with the similar structure*/
data have;
informat "Completion Date"N mmddyy10. ;
format "Completion Date"N mmddyy10. ;
input
"Completion Date"N;
run;

here is the output
1/11/2016 01:50 PM America/New York
NOTE: Invalid data for 'Completion Date'n


i believe I get this invalid message due to the Completion Date not actually
being a format mmddyy10. It has some text in it

Is there a way to reconfigure the informat or format to account for the
desired mmddyy10 date and the timezone that accompanies this???


You don't show a source for what you are reading with the INPUT. You should have either an INFILE statement or/and a cards/datalines block.

 

This does not shown any error when the Validvarname=any option is in effect:

data have;
informat "Completion Date"N mmddyy10. ;
format "Completion Date"N mmddyy10. ;
input "Completion Date"N;
datalines;
1/11/2016 01:50 PM America/New York
;

So you need to provide the actual stuff you ran, from the log that is showing the error. Copy the text from your log, open a text box on the forum with the </> and then paste the copied text. The text box in important because the typical error messages with invalid data will show several lines in the log that use a monospace font for layout and that is important. The message windows will reformat text making the diagnostics from the log less useful and hard to read.

 

Sajid01
Meteorite | Level 14

Hello @Q1983 
Can you post your functional code with a sample data?

Q1983
Lapis Lazuli | Level 10

Lets try this a different way.  I attempted to replicate the issue in a sample dataset

Data have;
infile cards truncover;
input email $20. first $30. last $30. age $3. completion_date $40.;
cards;
joesmith@email.com charles smith 1/11/2016 01:50 PM America/New York
ryna@email.com dennis jones 22 1/1/2016 01:50 PM America/Washington
;
run;

Is there a way to bring in the data and account for the variations in the character size without having to specify the length (ie email $20. what if I get a longer email address)  I inserted truncover to account for missing data.  As for the date the character size may vary.  is there a way to account for this without having to estimate the character size

Sajid01
Meteorite | Level 14

Hello @Q1983 
While there could be multiple approaches to address the issue, with the sample data you have provided,

I would follow the following approach, I would like to have the data as csv.
My code would be as follows:
Please note I have reordered your variables. We would need to define a length for the Email column.

data have (drop=_completion_date);
infile cards DLM=',' dsd;
Retain First Last Age Completion_date Email;
length Email $ 50  _completion_date $ 50;
format Completion_date mmddyy10.;
input  Email $ First $ Last $ Age   _completion_date $ ;
Completion_date=input(scan(_completion_date,1,''),mmddyy10.);
cards;
joesmith@email.com,	Charles,	Smith ,, 1/11/2016 01:50 PM America/New York
ryna@email.com	,	Dennis	,Jones , 22, 1/1/2016 01:50 PM America/Washington
;
run;

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 782 views
  • 0 likes
  • 4 in conversation