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

Hi,

I get an error message that I don't understand when I use the SAS CALMAR macro to calculate the weights. I read the documentation and apply it but it doesn't work. Even the example given in the documentation does not work for us.

Here is my data and the Squid macro. Can anyone help me or someone who has already used this SAS Calmar macro can explain to me what is wrong in my code or if I forgot a line of code before running the macro SAS CALMAR.

Thanks in advance.
Gick





data BDD_recod; input Nom $ sexe $ X $ Pond ; datalines; Jean Masculin 0-4ans 10 Marie Feminin 5-14ans 10 Pierre Masculin 15-24ans 10 J Feminin 0-4ans 10 M Feminin 5-14ans 10 Pe Masculin 0-4ans 10 Je Masculin 15-24ans 10 Ma Masculin 0-4ans 10 Pire Feminin 25-30ans 10 Mfir Feminin 35-40ans 10 Pell Masculin 40-45ans 10 Jeurs Masculin 15-24ans 10 Mam Masculin 0-4ans 10 Piress Feminin 15-24ans 10 ; data marges_cibles; input VAR $ N MAR1-MAR6 ; Cards; sexe 2 67866 80149 . . . . X 6 33065.5 39023 35281 21382 11561 7702 ; %CALMAR(DATA=BDD_recod, POIDS=Pond, IDENT=Nom, DATAMAR=marges_cibles, M=2,EDITPOI=OUI,OBSELI=OUI,DATAPOI=SORTIE,POIDSFIN=PONDFIN,LABELPOI=pondération raking ratio)

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

That page seems to only have SAS CATALOG files.  They MIGHT have a COMPILED version of the macro.  But compiled SAS macros are not PORTABLE.

 

But it does have a link to a GITHUB repository, https://github.com/InseeFr/Calmar/blob/main/Calmar.sas , where you can get the actual macro definition.

 

But the %MACRO statement in that code file has the / STORE option on it which cause attempts to compile to fail with this error message:

ERROR: The MSTORED option must be set to use the /STORE macro statement option.
ERROR: A dummy macro will be compiled.

 

So first REMOVE that /STORE option.

Then compile the macro.

Then try the examples.

 

You might also have trouble with the character set used in the macro definition.  And of course the documentation all appears to be in French.

Un petit exemple de calage sur marges                                                         12:14 Thursday, September 28, 2023   8


                           **********************************
                           ***   Param?tres de la macro   ***
                           **********************************


 Table en entr?e                     DATA      =  DON
  Pond?ration initiale               POIDS     =  POND
  Pond?ration Qk                     PONDQK    =  __UN
  Identifiant                        IDENT     =  NOM

 Table des marges                    DATAMAR   =  MARGES
  Marges en pourcentages             PCT       =  NON
  Effectif de la population          EFFPOP    =

 M?thode utilis?e                    M         =  2
  Borne inf?rieure                   LO        =
  Borne sup?rieure                   UP        =
  Seuil d'arr?t                      SEUIL     =  0.0001
  Nombre maximum d'it?rations        MAXITER   =  15

 Table contenant la pond. finale     DATAPOI   =  SORTIE
  Mise ? jour de la table DATAPOI    MISAJOUR  =  OUI
  Pond?ration finale                 POIDSFIN  =  PONDFIN
  Label de la pond?ration finale     LABELPOI  =  pondération raking ratio
  Contenu de la table DATAPOI        CONTPOI   =  OUI

 Edition des poids                   EDITPOI   =  OUI
  Statistiques sur les poids         STAT      =  OUI

 Contr?les                           CONT      =  OUI
 Table contenant les obs. ?limin?es  OBSELI    =  OUI
 Notes SAS                           NOTES     =  NON

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

When you get an error in the code, SHOW US the log. We need to see the ENTIRE log for the PROC or DATA step that has the error. 

Since you get an error in a macro, please turn on the macro debugging option by running this line of code and then run the macro again, and then show us the log for this PROC or DATA step that has the error.

 

options mprint;

 

Copy the log for the PROC or DATA step that has the error and paste it into the window that appears when you click on the </> icon.

PaigeMiller_0-1663012019648.png


Also, it would help if you gave us a link to the CALMAR macro.

--
Paige Miller
Gick
Pyrite | Level 9
In fact, it is a macro developed by INSEE and in the documentation https://www.insee.fr/fr/statistiques/fichier/2021902/doccalmar.pdf
and the web https://www.insee.fr/fr/information/2021902 , you just have to download the SAS code of the macro and then call it.

I just applied the example given in the macro documentation. I don't know why this isn't working for me.
PaigeMiller
Diamond | Level 26

@Gick wrote:

I just applied the example given in the macro documentation. I don't know why this isn't working for me.

I asked to see the log, I gave specific details on what I want to see and how to present it. Thanks!

--
Paige Miller
Gick
Pyrite | Level 9
Yes, I understood your question but the macro was not developed by me but by INSEE. She put the documentation to use it without putting how she programmed certain macro variables. I will have difficulty answering your question concretely because I am just using the macro
Tom
Super User Tom
Super User

That page seems to only have SAS CATALOG files.  They MIGHT have a COMPILED version of the macro.  But compiled SAS macros are not PORTABLE.

 

But it does have a link to a GITHUB repository, https://github.com/InseeFr/Calmar/blob/main/Calmar.sas , where you can get the actual macro definition.

 

But the %MACRO statement in that code file has the / STORE option on it which cause attempts to compile to fail with this error message:

ERROR: The MSTORED option must be set to use the /STORE macro statement option.
ERROR: A dummy macro will be compiled.

 

So first REMOVE that /STORE option.

Then compile the macro.

Then try the examples.

 

You might also have trouble with the character set used in the macro definition.  And of course the documentation all appears to be in French.

Un petit exemple de calage sur marges                                                         12:14 Thursday, September 28, 2023   8


                           **********************************
                           ***   Param?tres de la macro   ***
                           **********************************


 Table en entr?e                     DATA      =  DON
  Pond?ration initiale               POIDS     =  POND
  Pond?ration Qk                     PONDQK    =  __UN
  Identifiant                        IDENT     =  NOM

 Table des marges                    DATAMAR   =  MARGES
  Marges en pourcentages             PCT       =  NON
  Effectif de la population          EFFPOP    =

 M?thode utilis?e                    M         =  2
  Borne inf?rieure                   LO        =
  Borne sup?rieure                   UP        =
  Seuil d'arr?t                      SEUIL     =  0.0001
  Nombre maximum d'it?rations        MAXITER   =  15

 Table contenant la pond. finale     DATAPOI   =  SORTIE
  Mise ? jour de la table DATAPOI    MISAJOUR  =  OUI
  Pond?ration finale                 POIDSFIN  =  PONDFIN
  Label de la pond?ration finale     LABELPOI  =  pondération raking ratio
  Contenu de la table DATAPOI        CONTPOI   =  OUI

 Edition des poids                   EDITPOI   =  OUI
  Statistiques sur les poids         STAT      =  OUI

 Contr?les                           CONT      =  OUI
 Table contenant les obs. ?limin?es  OBSELI    =  OUI
 Notes SAS                           NOTES     =  NON
Reeza
Super User

What is the error message you receive?

 

You could have missed a semicolon or compiled the macro wrong....in fact your code doesn't show the macro compilation step

Which is why we need to see the log.

 


@Gick wrote:

Hi,

I get an error message that I don't understand when I use the SAS CALMAR macro to calculate the weights. I read the documentation and apply it but it doesn't work. Even the example given in the documentation does not work for us.

Here is my data and the Squid macro. Can anyone help me or someone who has already used this SAS Calmar macro can explain to me what is wrong in my code or if I forgot a line of code before running the macro SAS CALMAR.

Thanks in advance.
Gick





data BDD_recod; input Nom $ sexe $ X $ Pond ; datalines; Jean Masculin 0-4ans 10 Marie Feminin 5-14ans 10 Pierre Masculin 15-24ans 10 J Feminin 0-4ans 10 M Feminin 5-14ans 10 Pe Masculin 0-4ans 10 Je Masculin 15-24ans 10 Ma Masculin 0-4ans 10 Pire Feminin 25-30ans 10 Mfir Feminin 35-40ans 10 Pell Masculin 40-45ans 10 Jeurs Masculin 15-24ans 10 Mam Masculin 0-4ans 10 Piress Feminin 15-24ans 10 ; data marges_cibles; input VAR $ N MAR1-MAR6 ; Cards; sexe 2 67866 80149 . . . . X 6 33065.5 39023 35281 21382 11561 7702 ; %CALMAR(DATA=BDD_recod, POIDS=Pond, IDENT=Nom, DATAMAR=marges_cibles, M=2,EDITPOI=OUI,OBSELI=OUI,DATAPOI=SORTIE,POIDSFIN=PONDFIN,LABELPOI=pondération raking ratio)

 


 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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