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-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
  • 978 views
  • 0 likes
  • 4 in conversation