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;


 

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!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 570 views
  • 0 likes
  • 3 in conversation