BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I use the code -

data week;
set sales;
week_var = INTCK('WEEK','01/11/2009','07/11/2009');
proc print data = week;
run;

It gives me an error in log-

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
115:27 115:40
NOTE: Invalid numeric data, '01/11/2009' , at line 115 column 27.
NOTE: Invalid numeric data, '07/11/2009' , at line 115 column 40.
TransactionID=RX000152 DateofSale=03/11/2009 TimeofSale=11:27:53 LaptopModel=AP3965 UnitsSold=5


I have monthly data starts from 01/11/2009 and continue till 29/11/2009. I need to get summary data for each week and so have used the week().Kindly suggest the correction in code.

regards ,
markc
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You are attempting to use SAS CHARACTER type variables where the documented expectation is that you are supplying a SAS numeric (date or datetime) variable.

I'm not going to continue to post DOC links and suggestions that go unheeded.

Honestly, to the OP MarkC, you really need to digest and learn from your posts when received and not simply move on to another request from your boss or whatever. It will help drastically with your future SAS programming productivity and effectiveness, if that's your intention and quest.

So, regarding this post: I suggest strongly that you read up on SAS DATE, TIME and DATETIME variables, and also (for this exercise) you will want to pay attention to how to code a SAS DATE literal as an argument to INTCK (and INTNX for that matter).

Scott Barry
SBBWorks, Inc.
Bill
Quartz | Level 8
the date strings have to be converted into sas date values for sas to understand them
try
week_var = INTCK('WEEK',input('01/11/2009',date9.),input('07/11/2009',date9.));
MikeZdeb
Rhodochrosite | Level 12
hi ... INTCK requires numeric variables as arguments

if you are specifying the dates as literals, express your dates a bit differently and use a date constant ...
[pre]
data _null_;
week_var = INTCK('WEEK', '11jan2009'd , '11jul2009'd);
put "WEEK_VAR: " week_var;
run;

LOG ...
WEEK_VAR: 25
[/pre]
if there's a date already in the data ...
[pre]
data test;
input dt : mmddyy. @@;
week_var = INTCK('WEEK', '11jan2009'd , dt);
format dt mmddyy10.;
datalines;
02/10/2009 03/07/2009 12/15/2009
;
run;

proc print data = test;
run;

OUTPUT ...
Obs dt week_var
1 02/10/2009 4
2 03/07/2009 7
3 12/15/2009 48
[/pre]

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!

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.

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
  • 3 replies
  • 1219 views
  • 0 likes
  • 4 in conversation