BookmarkSubscribeRSS Feed
Beto16
Obsidian | Level 7
I have a data step
Data _null;
Z=-1;
Call symputx ('y' ,z);
Run;
%put &y;
Data _null_;
Length DOWN $10;
X=weekday (today ()&y);
If x=1 then DOW = 'Sunday';
If x=2 then DOW = 'M
If x =3 then DOW = 'Tuesday';

If x=1 then DOW = 'Wednesday';
If x=1 then DOW = 'thursday';

If x=1 then DOW = 'friday';
If x=1 then DOW = 'Saturday ';

Call symput('DOW','DOW');
Run;
%put &DOW;
DATA _NULL_; START_DATE=TODAY ()&Y;
IF WEEKDAY (START_DATE)=1 THEN START_DATE =START_DATE-1;
CALL SYMPUT ('DT', " ' "||PUT (START_DATE,date.)||" '");
Run;
In my andstatenent and al1.start_time = &dt1.

Error log
CLI PREPARE ERROR. TERADATA A CHARACTER STRING FAILED TO CONVERSION TO NUMERIC VALUE. The dt1. Resolves to 30oct16



5 REPLIES 5
Reeza
Super User

This doesn't make a whole lot of sense. Why multiply the date by -1, that will cause issues down the road. You have multiple checks for day of week 1?

 

 

1. Look at DOWNAME format. 

%let dow=%sysfunc(today(), downame.);
%put &dow.;

2. Where is the error being generated from? You've posted a lot of code - what's the actual issue?

3. I don't see the keyword BETWEEN so not sure what you're referring to here. 

 

Reeza
Super User

If you're trying to increment the date use the INTNX function rather than -1 to make sure it evaluates properly. 

ballardw
Super User

You have a Teradata error but do no show any connection, so missing some information.

Also putting quotes into macro variables frequently causes issues and your DT varaible has spaces inside the single quotes which may be even more problematic depending on use.

 

I would also suggest use of DATE9. so that you have a 4 digit year just in case year values become an issue. Some other program may assume that 16 is 1916.

Shmuel
Garnet | Level 18

If you don't expect years like 19xx in your data then add to your code:

     options yearcutoff = 2000;

LinusH
Tourmaline | Level 20

You don't show the actual Teradata call, so a bit guessing here.

If you are using implicit pass through (using Libname to Teradata), I assume that you need to use a SAS date literal, you can either extend your macro variable, or add it at macro variable resolution.

 

If you are using explicit pass through, you need a format that Terdata accepts, and chances are that they prefer a ISO date.

Data never sleeps

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1775 views
  • 0 likes
  • 5 in conversation