3

My datalines has 2 variables, date 1 and date 2 with corresponding format ddmmyy10. and mmddyy10.

data date;
    input date1 ddmmyy10. date2 mmddyy10.;
    datalines;
09/01/2015 01/09/2015
10/01/2015 01/10/2015
11/01/2015 01/11/2015
12/01/2015 01/12/2015
13/01/2015 01/13/2015
    ;
run;

I tried to add the code but still not work

infile datalines delimiter=' ';

2 Answers 2

7

The : (colon) format modifier enables you to use list input but also to specify an informat after a variable name, whether character or numeric. SAS reads until it encounters a blank column, the defined length of the variable (character only), or the end of the data line, whichever comes first.

Format Modifier

data date;
input date1: ddmmyy10. date2: mmddyy10.;
datalines;
09/01/2015 01/09/2015
10/01/2015 01/10/2015
11/01/2015 01/11/2015
12/01/2015 01/12/2015
13/01/2015 01/13/2015
;
run;
Sign up to request clarification or add additional context in comments.

Comments

7

The reason why the code is not working is because you are using List input to read non-standard data without colon input modifier or informat statement.

For non-standard data(commas, dollar, date etc. -> Reading Raw data -> Kinds of Data ) or standard data of length greater than 8 byte using List input technique you would need to use either INFORMAT statement or colon modifier with INPUT statement.

1) Assign informat for the input variables using INFORMAT statement or ATTRIB statement

data date;
  informat date1  ddmmyy10. date2 mmddyy10.;
  input date1  date2;
  format date1-date2 yymmdd10.;
datalines;
09/01/2015 01/09/2015
10/01/2015 01/10/2015
;
run;

2) Use Colon (:) input modifier

data date;
input date1: ddmmyy10. date2: mmddyy10.;
format date1-date2 yymmdd10.;
datalines;
09/01/2015 01/09/2015
10/01/2015 01/10/2015
;
run;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.