BookmarkSubscribeRSS Feed
mc
Fluorite | Level 6 mc
Fluorite | Level 6

Hi all. I been trying to call a character macro variable in an integrity constraint in Dataset procedure inside a macro. It is resolving to the correct string, but the results say " Add/Update failed for data set MCB.TABLE_PRODUCTS because data value(s) do

not comply with integrity constraint aa_mes". However, all my observations have the character value of 201507 for the variable aa_mess. The following is a sample of my code:

 

%macro table_prod(new1,set1,month1);
proc datasets library=&lib nolist;
 modify &new1;
   ic create fecha_proc = not null(fecha_proc);
   ic create aa_mes = check(where=(aa_mes = "&month1"));
   ic create id_clte = not null(id_clte);
   ic create Id_prod = not null(id_prod);
  run;

 append base=&lib..&new1 data=&lib..correct&set1;
 run;
quit;

%mend table_prod;

%table_prod(table_products,productos_201507,201507);

 

I may nto be writing the write code for call a character macro variable or maybe SAS is confused whether it is numeric or a character since it contains numbers. I'll be very appreciative if anyone sees the error in the code that could help me fix my issue.

5 REPLIES 5
Reeza
Super User
What does a proc contents show for that variable, aa_mes?
mc
Fluorite | Level 6 mc
Fluorite | Level 6
The variable aa_mes only has description of TYPE and LEN, which are Char and 7 respectively.
Reeza
Super User
7? You're providing a 6 char, try adding a trailing space to your comparison? You can also try your where comparison in a data step and see if it works.
FreelanceReinh
Jade | Level 19

A trailing space wouldn't matter. I rather suspect a leading blank.

 

What does the output of the following step look like?

proc sql;
select distinct put(aa_mes, $hex14.)
from &lib..correctproductos_201507
where aa_mes ne '201507';
quit;
LinusH
Tourmaline | Level 20

Not sure if I see the benefit of using a check constraint of something that easily can solve with a normal where-clause.

Also, usually not too fond of physically separate data by time period. Makes query much harder (unless you will use them as members in a SPD Server cluster).

Data never sleeps

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 1330 views
  • 0 likes
  • 4 in conversation