How to convert a given date value into SAS date

Answers were Sorted based on User's Feedback



How to convert a given date value into SAS date..

Answer / ranjith

we can store date values using date format
(ex:date9.,ddmmyyyy10.)

Is This Answer Correct ?    32 Yes 3 No

How to convert a given date value into SAS date..

Answer / arish kumar

e.g the date is '05/09/2007'

we can use the input function to convert this string into SAS date i.e.
date='05/09/2007'
sasdate=input(date,mmddyy10.);

Also, we can use mdy function.For this first use substr function.

m=substr(date,4,2);
d=substr(date,1,2);
y=substr(date,7,4);
sasdate=mdy(m,d,y);

Is This Answer Correct ?    21 Yes 3 No

How to convert a given date value into SAS date..

Answer / vipin choudhary

We can read the date value with the help of date informats.
Say we have the date 09/13/2008.
Now if we want SAS to read this date, we will use the date
informat in the input statement like
"input date mmddyy10."
SAS will store this date in the numerical form as the
number of days passed from 1st january, 1960.

Is This Answer Correct ?    12 Yes 3 No

How to convert a given date value into SAS date..

Answer / geoffrey brent

If you don't know in advance how the date will be
formatted, you can use the ANYDTDTE. informat. This will
extract a SAS date from most date/date-time formats.
(Warning: ANYDTDTE doesn't fully support day-month-year
ordering, even if you have this set as your system
preference, but it still copes with most DMY-formatted
dates.)

Is This Answer Correct ?    9 Yes 1 No

How to convert a given date value into SAS date..

Answer / komal

For example if we have a date="14/12/2008".

you have to input it first and the format it like
date1=input(date,ddmmyy10.);
format date1 ddmmyy10.;
run;

Is This Answer Correct ?    8 Yes 1 No

How to convert a given date value into SAS date..

Answer / srinivas krishnan

in sas :: we can store like this `12-07-2009`d

Is This Answer Correct ?    5 Yes 1 No

How to convert a given date value into SAS date..

Answer / vinay

/*let date is '10/07/1985'/*
/*SAS CODING*/
data date;
input date $;
Var_Date=input(date,mmddyy10.);/*Apply format within input
function to convert text value to number value*/
/*now extract value of month,date and year through date
functions*/
m=substr(Var_Date,4,2);
d=substr(Var_Date,1,2);
y=substr(Var_Date,7,4);
sasdate=mdy(m,d,y);
cards;
10/07/1985
;
run;
proc print dtat=date;
run;

Is This Answer Correct ?    2 Yes 0 No

How to convert a given date value into SAS date..

Answer / sheetal

data temp;
date='17/12/2009';
m=substr(date,4,2);
d=substr(date,1,2);
y=substr(date,7,4);
d1=mdy(m,d,y);
format d1 mmddyy10.;
run;

Is This Answer Correct ?    5 Yes 5 No

How to convert a given date value into SAS date..

Answer / suresh ganapuram

Actually sas stores dates as numbers

eg:: given date 12-07-2009


in sas :: we can store like this `12-07-2009`d

Is This Answer Correct ?    10 Yes 16 No

Post New Answer

More SAS Interview Questions

How would you combine 3 or more tables with different structures?

7 Answers  


How would you code the criteria to restrict the output to be produced?

6 Answers   Accenture,


Describe the function and utility of the most difficult SAS macro that you have written?

0 Answers   Oracle,


what is sas and what are the functions? : Sas-administrator

0 Answers  


how can you sort the dataset having millions of OBS(instead of sort procedure?

4 Answers   EXL,






how to get second highest salary from a employee table and how get a 5th highest salary from a employee table?

11 Answers   ABC, Amex,


Name statements that function at both compile and execution time.

3 Answers   L&T,


How would you code a merge that will write the matches of both to one data set, the non-matches from the left-most data?

0 Answers  


explain the main difference between the nodup and nodupkey options? : Sas-administrator

0 Answers  


What is the length assigned to the target variable by the scan function?

0 Answers  


Dear all, proc means data=dsn noprint completetypes; class trtmntgroup /preloadfmt; output out=tot n=n; format trtmntgroup trtf. ; by vstgrp descending severity; run; This is the code I used for AE table. I got the values without giving the variable ‘trtmntgroup(numeric)’ in var statement. And if I give the var statement for that variable i’m getting the same values.How is that possible? What is the difference between class and var statement? Could any one explain me how does proc means work at the back end. And what is the difference between _freq_ value and N value in proc means. Thanks and regards, Rajesh.

1 Answers  


If a variable contains only numbers, can it be a character data type?

0 Answers  


Categories