BookmarkSubscribeRSS Feed
BURHAN_CIGDEM
Fluorite | Level 6

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.

5 REPLIES 5
PaigeMiller
Diamond | Level 26

 

data want;
    set have;
    if tarih>=intnx('week',today(),-13,'s');
    /* ALTERNATIVE: if tarih >= today()-13*7; */
run;
--
Paige Miller
BURHAN_CIGDEM
Fluorite | Level 6
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?
PaigeMiller
Diamond | Level 26

@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
BURHAN_CIGDEM
Fluorite | Level 6
There is no any problem on SASLog but I can see all obs in output data, not just last 13.
PaigeMiller
Diamond | Level 26

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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