BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
kimmialex
Calcite | Level 5

I used this code, but I have over 8,000 observations. When I use this code, I only see my first three observations. I am sure there is an easier code without putting each dataline in. Thanks for the help

 

data deaths;
input year day month;
format new ddmmyy8.;
new=mdy(month,day,year);
datalines;
1999 1 1
1999 1 2

1999 1 3
;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
data new;
set oldDataSet;

newDate = mdy(month, day, year);
format newDate ddmmyy8.;

run;

Assuming you already have a data set with the day, month, year referencing it with a SET statement instead is what you want to do. 

 


@kimmialex wrote:

I used this code, but I have over 8,000 observations. When I use this code, I only see my first three observations. I am sure there is an easier code without putting each dataline in. Thanks for the help

 

data deaths;
input year day month;
format new ddmmyy8.;
new=mdy(month,day,year);
datalines;
1999 1 1
1999 1 2

1999 1 3
;
run;


 

View solution in original post

2 REPLIES 2
ballardw
Super User

I don't see anything combining "three columns" so it appears that you have skipped a bunch of step, like how you combined, what on, what your start looks like and what you expect the result to look like.

 

If you mean "create a date variable" from month, day and year variable you have the right function (likely) but you don't show the use of any existing data set which would go on a set statement such as:

data newdataset;
   set existingdatasetname;
   format new ddmmyy8.;
   /* assuming the data set on the SET statement 
     has numeric variables named month, day and year
     and year is 4 digits*/
   new=mdy(month,day,year);
run;

If "deaths" was the name of your data set you have replaced it and need to re-create it.

Reeza
Super User
data new;
set oldDataSet;

newDate = mdy(month, day, year);
format newDate ddmmyy8.;

run;

Assuming you already have a data set with the day, month, year referencing it with a SET statement instead is what you want to do. 

 


@kimmialex wrote:

I used this code, but I have over 8,000 observations. When I use this code, I only see my first three observations. I am sure there is an easier code without putting each dataline in. Thanks for the help

 

data deaths;
input year day month;
format new ddmmyy8.;
new=mdy(month,day,year);
datalines;
1999 1 1
1999 1 2

1999 1 3
;
run;


 

sas-innovate-white.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.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 976 views
  • 0 likes
  • 3 in conversation