DATA Step, Macro, Functions and more

Date format for API Call

Reply
Occasional Contributor
Posts: 6

Date format for API Call

I am using the following two lines to get beginning and end dates needed for an api request. I have another api request where the time must be included as well. It looks like "2018-04-01T00:00:00-07:00" I do not understand -07:00 at all. But this is what I need.

 

Is there a time format I can use to get this or a way to "text" it in after the date entry in the url string?

 

filename criteo '/opt/sas/data/sasuser/sn161735/criteo.json';

 

data test;

  enddate=today()-1;

  begindate=intnx('qtr',enddate,0,'b');

  token='xx';

  length url $300 ;

  url=quote(cats('https://publishers.criteo.com/api/2.0/stats.json?apitoken=',token

   ,'&begindate=',put(begindate,yymmddd10.)

   ,'&enddate=',put(enddate,yymmddd10.)

   ,'&metrics=Date;TotalImpression;CPM;Revenue;WinRate'

   ),"'");

  call symputx('url',url);

  call symputx('webusername',quote("x"rk));

  call symputx('webpassword',quote("x"));

run;

 

proc http url=&url method="GET" out=criteo

  webusername=&webusername

  webpassword=&webpassword

  AUTH_BASIC

;

run;

 

libname criteo json fileref=criteo;

 

PROC SQL;

   CREATE TABLE CRITEO_DATA AS

   SELECT t1.date,

          t1.totalImpression FORMAT=COMMA9. AS totalImpression,

          t2.value FORMAT=DOLLAR9.2 AS Revenue,

          t3.value FORMAT=DOLLAR6.2 AS CPM

      FROM CRITEO.ROOT t1, CRITEO.REVENUE t2, CRITEO.CPM t3

      WHERE (t1.ordinal_root = t2.ordinal_root AND t1.ordinal_root = t3.ordinal_root);

QUIT;

Super User
Posts: 12,996

Re: Date format for API Call

That looks like the E8601DX. format. The last bit, -07:00 is your timezone offset.

Ask a Question
Discussion stats
  • 1 reply
  • 69 views
  • 1 like
  • 2 in conversation