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

I am converting the date that shows up as yyyy/mm/dd in a character format to a numeric 

this is what proc contents looks like for the original data

 

proc contents data = work.vchange;
run;

Variable Type Len Format Informat Label

HepB_DAteChar10$10.$10.hepbdate

 

and this is the code i am using to convert the data 

 

data vchange2;
set work.vchange;
hbv2 = input(hepb_date, 10.);
format hbv2 yymmdd.;
run;

 

and the error that comes up is:

NOTE: Invalid argument to function INPUT at line 71 column 8.

HepB_DAte=2010/01/01

 

can someone help with this?

thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

The INFORMAT is incorrect, it needs to be the informat that matches how the data appears, basically it tells SAS how the variable appears and how it should be read in. 

If your data shows as YYYY/MM/DD then it should be YYMMDD10.

Note that this was one of the same issues in your previous question.

 

data vchange2;
set work.vchange;
hbv2 = input(hepb_date, YYMMDD10.);
format hbv2 yymmdd.;
run;

 

@Cooksam13 wrote:

I am converting the date that shows up as yyyy/mm/dd in a character format to a numeric 

this is what proc contents looks like for the original data

 

proc contents data = work.vchange;
run;

Variable Type Len Format Informat Label

HepB_DAte Char 10 $10. $10. hepbdate

 

and this is the code i am using to convert the data 

 

data vchange2;
set work.vchange;
hbv2 = input(hepb_date, 10.);
format hbv2 yymmdd.;
run;

 

and the error that comes up is:

NOTE: Invalid argument to function INPUT at line 71 column 8.

HepB_DAte=2010/01/01

 

can someone help with this?

thanks

 


 

View solution in original post

1 REPLY 1
Reeza
Super User

The INFORMAT is incorrect, it needs to be the informat that matches how the data appears, basically it tells SAS how the variable appears and how it should be read in. 

If your data shows as YYYY/MM/DD then it should be YYMMDD10.

Note that this was one of the same issues in your previous question.

 

data vchange2;
set work.vchange;
hbv2 = input(hepb_date, YYMMDD10.);
format hbv2 yymmdd.;
run;

 

@Cooksam13 wrote:

I am converting the date that shows up as yyyy/mm/dd in a character format to a numeric 

this is what proc contents looks like for the original data

 

proc contents data = work.vchange;
run;

Variable Type Len Format Informat Label

HepB_DAte Char 10 $10. $10. hepbdate

 

and this is the code i am using to convert the data 

 

data vchange2;
set work.vchange;
hbv2 = input(hepb_date, 10.);
format hbv2 yymmdd.;
run;

 

and the error that comes up is:

NOTE: Invalid argument to function INPUT at line 71 column 8.

HepB_DAte=2010/01/01

 

can someone help with this?

thanks

 


 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 263 views
  • 0 likes
  • 2 in conversation