SAS Procedures

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

Whats the best way to format monthstart and end dates to use in a teradata passthrough query in SAS,

below is a bit of code that formats todays date in to teradata format but not sure who to do the monthstart and monthend in the same format.

any help is appreciated

data _null_;

call symput('yyyymmdd',compress(put((intnx('day',today(),1)-1),yymmdd10.),"-"));

run;

%put &yyyymmdd;

data x;

format yymmdd $7.;

yymmdd = substr(&yyyymmdd.,7,6);

VAR = "1";

New_Date = cat(VAR,yymmdd);

drop yymmdd var;

run;

%global td_dte;

proc sql;

select New_Date into: td_dte

from x;

quit;

%put &td_dte;

proc sql; drop table x; quit;

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

I'm not familiar with Teradata but following your logic how about something like this:

data _null_;

  today = today();

  month_start = intnx('MONTH', today, 0, 'BEGINNING');

  month_end = intnx('MONTH', today, 0, 'END');

  call symput('today', '1' !! put(today, yymmddn6.));

  call symput('month_start', '1' !! put(month_start, yymmddn6.));

  call symput('month_end', '1' !! put(month_end, yymmddn6.));

run;

%put &today &month_start &month_end;

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

I'm not familiar with Teradata but following your logic how about something like this:

data _null_;

  today = today();

  month_start = intnx('MONTH', today, 0, 'BEGINNING');

  month_end = intnx('MONTH', today, 0, 'END');

  call symput('today', '1' !! put(today, yymmddn6.));

  call symput('month_start', '1' !! put(month_start, yymmddn6.));

  call symput('month_end', '1' !! put(month_end, yymmddn6.));

run;

%put &today &month_start &month_end;

Wickywick
Calcite | Level 5

Thanks SASKiwi it works, very much appreciated.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 5573 views
  • 0 likes
  • 2 in conversation