DATA Step, Macro, Functions and more

Need to change the format of date in excel.

Reply
New Contributor
Posts: 2

Need to change the format of date in excel.

I am a newbie in SAS. And I got a data to solve.

 

The data contains date of birth and number of people who took insurance.
We need to find for each month how many people took insurance.

 

Arpit

Super User
Super User
Posts: 7,401

Re: Need to change the format of date in excel.

Hi,

 

This is a SAS forum, not an Excel one?  Has your data been imported to SAS?  If so can you show an example in the form of a datastep.  AS for the code once you have it in SAS then that is pretty easy:

proc sql;
  create table WANT as
  select  month(YOUR_DATE) as MON,
            count(PERSON) as NUMBER_OF_PEOPLE
  from    HAVE 
  group by month(YOUR_DATE);
quit;

Without seeing some test data and required output I am just guessing though (and no, I don't download Excel files).

Super User
Posts: 17,815

Re: Need to change the format of date in excel.

@Arpitgt Welcome to SAS. 

 

Your question isn't clear as to what you need help with. 

 

Depending on what you're trying to do, there's a lot of options. Are you having trouble importing the data, or calculating your measure of how many people each month took insurance?

 

Also, many people here do not download Excel files, so it's best to post your data in your question, a small sample at any rate.

New Contributor
Posts: 2

Re: Need to change the format of date in excel.

@Reeza 

 

I am having trouble to calculate how many people each month took insurance?

 

Below is the data for first 22 days in january. Remaining data is same as below for every month :-

 

date   no_of_births

1/1    1482

1/2    1213

1/3    1220

1/4    1319

1/5    1262

1/6    1271

1/7    1355

1/8    1219

1/9    1253

1/10  1339

1/11  1293

1/12  1295

1/13  1296

1/14  1333

1/15  1409

1/16  1330

1/17  1286

1/18  1268

1/19  1336

1/20  1422

1/21  1318

1/22  1302

 

 

Super User
Super User
Posts: 7,401

Re: Need to change the format of date in excel.

That would need some clarification, 

date   no_of_births

1/1    1482

1/2    1213

1/3    1220

 

What type is date, as 1/1 is not a date.  Is it a SAS numeric date variable, i.e. 01JAN2016 for example?  Is no_of_births a numeric variable?   For example:

data have;
  date="01JAN2016"d; no_of_births=1482; output;
  date="02JAN2016"d; no_of_births=1213; output;
run;
proc sql;
  create table WANT as
  select  distinct 
          month(DATE) as MON,
          sum(NO_OF_BIRTHS) as NUMBER_OF_BIRTHS
  from    HAVE 
  group by month(DATE);
quit;
Ask a Question
Discussion stats
  • 4 replies
  • 316 views
  • 2 likes
  • 3 in conversation