Desktop productivity for business analysts and programmers

Last 13 week's data

Reply
Occasional Contributor
Posts: 9

Last 13 week's data

Hi,

I have a SAS data set which contains 3 variables and 300 obs. Name of variables are Tarih, K1 and K2. Tarih variable is actually dates of data on weekly basis. Well, I wanna create a new SAS data set which includes last 13 weeks when I run the code every times.  How can I do that?

Thanks.

Respected Advisor
Posts: 3,288

Re: Last 13 week's data

[ Edited ]
Posted in reply to BURHAN_CIGDEM

 

data want;
    set have;
    if tarih>=intnx('week',today(),-13,'s');
    /* ALTERNATIVE: if tarih >= today()-13*7; */
run;
--
Paige Miller
Occasional Contributor
Posts: 9

Re: Last 13 week's data

Posted in reply to PaigeMiller
Thank you but it did not work. "Tarih" variable is stored as numeric variable. For example; 20180511(yyyymmdd). Should I convert it date format or something else?
Respected Advisor
Posts: 3,288

Re: Last 13 week's data

Posted in reply to BURHAN_CIGDEM

@BURHAN_CIGDEM wrote:
Thank you but it did not work. "Tarih" variable is stored as numeric variable. For example; 20180511(yyyymmdd). Should I convert it date format or something else?

Show us the SASLOG. Show us other evidence that it did not work. 

 

The code I wrote expects TARIH to be numeric.

 

--
Paige Miller
Occasional Contributor
Posts: 9

Re: Last 13 week's data

Posted in reply to PaigeMiller
There is no any problem on SASLog but I can see all obs in output data, not just last 13.
Respected Advisor
Posts: 3,288

Re: Last 13 week's data

Posted in reply to BURHAN_CIGDEM

Burhan, show us the code then. Show us (some of) the data. Don't keep replying without showing us what is happening. Show us.

--
Paige Miller
Ask a Question
Discussion stats
  • 5 replies
  • 176 views
  • 0 likes
  • 2 in conversation