diff --git a/doc/dynare.texi b/doc/dynare.texi
index 40aba5129ba09c131fa587d0e27189475f631ac0..9ddb19c4c853ad3e72e6ca7a314f476c104850a2 100644
--- a/doc/dynare.texi
+++ b/doc/dynare.texi
@@ -6867,7 +6867,8 @@ of the shock groups is written in a block delimited by @code{shock_groups} and
 Each line defines a group of shock as a list of exogenous variables:
 
 @example
-SHOCK_GROUP_NAME =  VARIABLE_1 [[,] VARIABLE_2 [,]@dots{}];
+SHOCK_GROUP_NAME   = VARIABLE_1 [[,] VARIABLE_2 [,]@dots{}];
+`SHOCK GROUP NAME' = VARIABLE_1 [[,] VARIABLE_2 [,]@dots{}];
 @end example
 
 @optionshead
@@ -6891,7 +6892,7 @@ varexo e_a, e_b, e_c, e_d;
 
 shock_groups(name=group1);
 supply = e_a, e_b;
-demand = e_c, e_d;
+`aggregate demand' = e_c, e_d;
 end;
 
 shocks_decomposition(use_shock_groups=group1);
diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy
index c6dd2fe7b9e548bf7d0417e7916819a893b86056..7f22d45d355a515b177712d35d00ebd73c55f677 100644
--- a/preprocessor/DynareBison.yy
+++ b/preprocessor/DynareBison.yy
@@ -2685,9 +2685,10 @@ shock_group_list : shock_group_list shock_group_element
                  | shock_group_element
                  ;
 
-shock_group_element : symbol EQUAL shock_name_list ';' {driver.add_shock_group($1);}
+shock_group_element : symbol EQUAL shock_name_list ';' { driver.add_shock_group($1); }
+                    | QUOTED_STRING EQUAL shock_name_list ';' { driver.add_shock_group($1); }
                     ;
-                    
+
 shock_name_list : shock_name_list COMMA symbol {driver.add_shock_group_element($3);}
                 | shock_name_list symbol {driver.add_shock_group_element($2);}
                 | symbol {driver.add_shock_group_element($1);}
diff --git a/preprocessor/Shocks.cc b/preprocessor/Shocks.cc
index 1216a40b463e650dc72787e0617f48baa1480563..af40262414e6dc343874707a73d11814580c7590 100644
--- a/preprocessor/Shocks.cc
+++ b/preprocessor/Shocks.cc
@@ -463,13 +463,29 @@ ShockGroupsStatement::ShockGroupsStatement(const group_t &shock_groups_arg, cons
 void
 ShockGroupsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
-  for (vector<Group>::const_iterator it = shock_groups.begin(); it != shock_groups.end(); it++)
+  int i = 1;
+  bool unique_label = true;
+  for (vector<Group>::const_iterator it = shock_groups.begin(); it != shock_groups.end(); it++, unique_label=true)
     {
-      output << "M_.shock_groups." << name
-             << "." << it->name << " = {";
-      for ( vector<string>::const_iterator it1 = it->list.begin(); it1 != it->list.end(); it1++)
-        output << " '" << *it1 << "'";
-      output << "};" << endl;
+      for (vector<Group>::const_iterator it1 = it+1; it1 != shock_groups.end(); it1++)
+        if (it->name == it1->name)
+          {
+            unique_label = false;
+            cerr << "Warning: shock group label '" << it->name << "' has been reused. "
+                 << "Only using the last definition." << endl;
+            break;
+          }
+
+      if (unique_label)
+        {
+          output << "M_.shock_groups." << name
+                 << ".group" << i << ".label = '" << it->name << "';" << endl
+                 << "M_.shock_groups." << name
+                 << ".group" << i << ".shocks = {";
+          for ( vector<string>::const_iterator it1 = it->list.begin(); it1 != it->list.end(); it1++)
+            output << " '" << *it1 << "'";
+          output << "};" << endl;
+          i++;
+        }
     }
 }
-