hi, i use sas 9.4
i got the following 2 Columns: year and day.
year is 2008.
day: 1 to 322.
1 means 1.1.2008 and so on...
how do i convert the numbers ito dates?
super urgent!! thanxxx
You showed what day=1 looks like. What should day=322 look like?
Art, CEO, AnalystFinder.com
Ok. Day 322 looks like '322', but means? ....
Does it mean the 322nd day of the year? Plus you said that it looks like '322'. Is that the number 322, or a character string?
Art, CEO, AnalystFinder.com
Assuming day is the sequential day in a year, you can calculatr the date as:
date = mdy(1,1,year) + day -1;
format day ddmmyy10. ; /* or any other date format, e.g date9. */
taht is, for year=2008 then date = Jan 1st, 2008 + day - 1;
If you have the year and the day input as yyyyddd
then you can also use:
data _NULL_;
date_in = '2016055'; /*year=2016 day=055 */
date = input(date_in, julian7.); /* Julian date informat */
put date date9.; /* check date in log */
run;
Tha synatx depends on your input.
Post a sample of your input file, better as data step to read it,
or maybe:
data have;
input date julian7. ;
format date date9.;
datalines;
2008200
2010035
2015106
;
run;
i have +300 rows... in colum 'day' i have number: 1-365, in colum 'year'= 2008.
i want to create anothe colum name 'date'- which will be the xx (from colum 'day') day of the year 2008.
for exemple: if i have the number 4 in 'day' colum, i want that it colum 'date' it will show: 4/1/2008.
Do you have the data already in a dataset? Or are you reading from a text file? If you are reading from a text file then the data step would look like this:
data want ;
infile 'myfile.txt' ;
input year day ;
date = mdy(1,1,year)+day-1;
format date date9.;
run;
If you have an existing SAS dataset then replace the INFILE and INPUT statements with a SET statement.
i have data in an exel file.
how will the syntax will be?
this way it is not working...
After importing, when you click on the file on SAS, what are the properties of each of those fields? Specifically, we need to know if each is character or numeric.
Art, CEO, AnalystFinder.com
is this helps?
informat year best32. ;
informat day best32.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.