Here is a simple code for creating DocumentSets programmatically and update metadata of it:
string strName = "<Name of the DocumentSet>";
SPContentTypeId cntntID = new SPContentTypeId();
cntntID = _docLib.ContentTypes["<DocumentSet content type name>"].Id;
Hashtable prop = new Hashtable();
DocumentSet _docSet = DocumentSet.Create(_fldr, strName, cntntID, prop, true);
SPListItem _docSetItem = _docLib.GetItemById(_docSet.Item.ID);
_docSetItem["<field>"]="<value>";
_docSetItem.Update();
Here _fldr is the SPFolder object, inside which we want to create document set.
_docLib is the SPDocumentLibrary object inside which document set has to be created.
string strName = "<Name of the DocumentSet>";
SPContentTypeId cntntID = new SPContentTypeId();
cntntID = _docLib.ContentTypes["<DocumentSet content type name>"].Id;
Hashtable prop = new Hashtable();
DocumentSet _docSet = DocumentSet.Create(_fldr, strName, cntntID, prop, true);
SPListItem _docSetItem = _docLib.GetItemById(_docSet.Item.ID);
_docSetItem["<field>"]="<value>";
_docSetItem.Update();
Here _fldr is the SPFolder object, inside which we want to create document set.
_docLib is the SPDocumentLibrary object inside which document set has to be created.