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

Here is the coding that I need to use:

PROC SQL;

   CREATE TABLE WORK.FILTER_FOR_XXXX AS

SELECT t1.sale_dt,

          t1.DUE_DT,

          t1.TOWN,

          t1.POSTAL_CD,

          t1.PROV_CD,

          t1.COMPETITION,

          t1.AGENT_CD,

          t1.STORE,

          t1.MRKT,

          t1.AGENT_ID,

     FROM WORK.FILTER_FOR_XXXX

      WHERE TOWN = 'NY' AND t1.sale_dt > 19724

      ORDER BY t1.sale_dt;

QUIT;


I have sale dates in variable t1.sale_dt appearing as for example 11JAN2014 (in French) etc.. I want to add to more variables one for the Month January (or 1) and the second for the Year 2014. Which exact coding should I add to have it please?


thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
dcruik
Lapis Lazuli | Level 10

This should work for you:

PROC SQL;  

CREATE TABLE WORK.FILTER_FOR_XXXX AS

SELECT t1.sale_dt,

month(t1.sale_dt) as Month format=2.,

year(t1.sale_dt) as Year format=4.,      

t1.DUE_DT,         

t1.TOWN,         

t1.POSTAL_CD,         

t1.PROV_CD,         

t1.COMPETITION,         

t1.AGENT_CD,         

t1.STORE,         

t1.MRKT,         

t1.AGENT_ID

FROM WORK.FILTER_FOR_XXXX     

WHERE TOWN = 'NY' AND t1.sale_dt > 19724     

ORDER BY t1.sale_dt;

QUIT;

View solution in original post

2 REPLIES 2
dcruik
Lapis Lazuli | Level 10

This should work for you:

PROC SQL;  

CREATE TABLE WORK.FILTER_FOR_XXXX AS

SELECT t1.sale_dt,

month(t1.sale_dt) as Month format=2.,

year(t1.sale_dt) as Year format=4.,      

t1.DUE_DT,         

t1.TOWN,         

t1.POSTAL_CD,         

t1.PROV_CD,         

t1.COMPETITION,         

t1.AGENT_CD,         

t1.STORE,         

t1.MRKT,         

t1.AGENT_ID

FROM WORK.FILTER_FOR_XXXX     

WHERE TOWN = 'NY' AND t1.sale_dt > 19724     

ORDER BY t1.sale_dt;

QUIT;

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
  • 2 replies
  • 855 views
  • 1 like
  • 2 in conversation