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

hi all,

i am trying to set the value for the column where date (date column contains timestamp also that is datetime19. format) is older than 7 years and iam using proc sql update option but getting following error. please help.

_
73
76
ERROR 73-322: Expecting an =.

ERROR 76-322: Syntax error, statement will be ignored.

proc sql;
vvv.jjj      set 
         jjj.id = 'FFFF'
      where jjj.date >=  %sysfunc(            
intnx( month, %sysfunc(today()), -6, same ), datetime19. ); ; quit;

 

1 ACCEPTED SOLUTION

Accepted Solutions
JJP1
Pyrite | Level 9

it is working if i try with below code please.

%let yera =
%sysfunc(intnx(year,%sysfunc(today()),-7,same),date9.);
proc sql;
   update vvv.jjj
      set 
         jjj.id = 'FFFF'
      where jjj.date >= "&yera"d
               ;
quit;

View solution in original post

8 REPLIES 8
Shmuel
Garnet | Level 18

It is impossible to understand which dataset you want to update.

You probably miss some keywords and have an erroneous syntax.

Please post the full log in the '</> window in order to keep indentation.  

JJP1
Pyrite | Level 9
proc sql;
   update vvv.jjj 
      set 
         jjj.id = 'FFFF'
      where jjj.date >=  %sysfunc(
            intnx(
            month,             
            %sysfunc(today()), 
            -6,                
            same               
            ), date9.  
           );
   ;
quit;

Updated @Shmuel  sorry for the error please

gamotte
Rhodochrosite | Level 12

Hello,

 

You can try as follows :

 

data have;
    format dt datetime19. id $4.;
    keep id dt;
    day=day(today());
    do i=0 to 10;
        id=put(i,best.);
        dt=dhms(intnx('day', today(),-i),0,0,0);
        output;
    end;
run;

proc sql noprint;
    UPDATE have
    SET id='FFFF'
    WHERE intck('day', datepart(dt), today())>6
    ;
quit;

JJP1
Pyrite | Level 9

Yes thanks @gamotte , but i want to understand where iam going wrong in my syntax please.

iam unable to identify the error in my code can anyone please suggest

gamotte
Rhodochrosite | Level 12

What message is displayed in the log ?

You can use date functions in proc sql so you don't need sysfunc.

Also, you compare a date and a datetime.

JJP1
Pyrite | Level 9

it is working if i try with below code please.

%let yera =
%sysfunc(intnx(year,%sysfunc(today()),-7,same),date9.);
proc sql;
   update vvv.jjj
      set 
         jjj.id = 'FFFF'
      where jjj.date >= "&yera"d
               ;
quit;
gamotte
Rhodochrosite | Level 12

It is generally preferable not to format date macrovariables, so you don't have to convert them back to date variables for comparisons.

 

%let yera =%sysfunc(intnx(year,%sysfunc(today()),-7,same));
proc sql;
   update vvv.jjj
      set 
         jjj.id = 'FFFF'
      where jjj.date >= &yera.
               ;
quit;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 8 replies
  • 1123 views
  • 1 like
  • 3 in conversation