Wolfram Data Repository
Immediate Computable Access to Curated Contributed Data
Information on new mothers from 1978 through 1988 from NLSY79
| In[1]:= | ![ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: New Mothers\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: New Mothers-Input",
AutoDelete->True]\)]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/0fddaf4b5426f59c.png) | 
| Out[1]= |  | 
Data dimensions:
| In[2]:= | ![Dimensions[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: New Mothers\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: New Mothers-Input",
AutoDelete->True]\)]]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/48a8cd6bbceeefbd.png) | 
| Out[2]= |  | 
Column keys and types:
| In[3]:= | ![ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: New Mothers\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: New Mothers-Input",
AutoDelete->True]\), "ColumnKeys"]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/47c92bfcbe9c9aef.png) | 
| Out[3]= |  | 
| In[4]:= | ![ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: New Mothers\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: New Mothers-Input",
AutoDelete->True]\), "ColumnTypes"]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/6f95285b9c745ef7.png) | 
| Out[4]= |  | 
Column descriptions:
| In[5]:= | ![ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: New Mothers\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: New Mothers-Input",
AutoDelete->True]\), "ColumnDescriptions"] // Dataset](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/3f4c6d9e4b6532a5.png) | 
| Out[5]= |  | 
Tabular structure of the data:
| In[6]:= | ![TabularStructure[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: New Mothers\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: New Mothers-Input",
AutoDelete->True]\)]]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/0431cf9d83cbb55b.png) | 
| Out[6]= |  | 
Histogram of the breast feeding durations:
| In[7]:= | ![Histogram[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: New Mothers\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: New Mothers-Input",
AutoDelete->True]\)] -> "duration", AxesLabel -> Automatic]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/2ceefe6304d4929a.png) | 
| Out[7]= |  | 
PieChart of the race distribution:
| In[8]:= | ![rc = AggregateRows[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: New Mothers\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: New Mothers-Input",
AutoDelete->True]\)], "count" -> Function[Length[#race]], "race"]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/64d1c7503d67c0f7.png) | 
| Out[8]= |  | 
| In[9]:= | ![PieChart[Normal[rc[All, "count"]], ChartLabels -> (Style[#, Bold, 12] & /@ Normal[rc[All, "race"]]), PlotTheme -> "Business", ImageSize -> Small]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/7a717f7ac68372c4.png) | 
| Out[9]= |  | 
Convert "birthyear" column to a date format:
| In[10]:= | ![TransformColumns[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: New Mothers\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: New Mothers-Input",
AutoDelete->True]\)], "birthyear" -> Function[DateObject[{1900 + #birthyear}, "Year"]]]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/33a309550274a42b.png) | 
| Out[10]= |  | 
| In[11]:= | ![ColumnTypes[%]["birthyear"]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/41c0c09a8f03bb19.png) | 
| Out[11]= |  | 
Compute mean breast feeding duration grouped by mother's age:
| In[12]:= | ![AggregateRows[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: New Mothers\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: New Mothers-Input",
AutoDelete->True]\)], "MeanDuration" -> Function[Mean[#duration]], "motherage"]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/530312af9fcb5f34.png) | 
| Out[12]= |  | 
Sort by the mother's age:
| In[13]:= | ![mda = Sort[%, "motherage"]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/0b612b5cecd3664b.png) | 
| Out[13]= |  | 
Visualize the mean breast feeding duration as a function of mother's age:
| In[14]:= | ![ListLinePlot[mda -> {"motherage", "MeanDuration"}, AxesLabel -> Automatic]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/7e46415a9910ab1c.png) | 
| Out[14]= |  | 
Compute mean breast feeding duration grouped by year of birth of child and alcohol use:
| In[15]:= | ![PivotTable[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: New Mothers\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: New Mothers-Input",
AutoDelete->True]\)], "MeanDuration" -> Function[Mean[#duration]], "birthyear", "alcohol"]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/148d592c690a7cef.png) | 
| Out[15]= |  | 
Sort by the birth year:
| In[16]:= | ![mdb = Sort[%, "birthyear"]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/792dddeab8b73c21.png) | 
| Out[16]= |  | 
Visualize the mean breast feeding durations as a function of child birth year and alcohol use:
| In[17]:= | ![ListLinePlot[
 mdb -> {{"birthyear", ExtendedKey["MeanDuration", True]}, {"birthyear", ExtendedKey["MeanDuration", False]}}, AxesLabel -> {"year", Automatic}, PlotLegends -> {"alcohol use", "no alcohol use"}]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/6593837b9dcaec8b.png) | 
| Out[17]= |  | 
Compute how many new mothers smoked and/or used alcohol at birth of child:
| In[18]:= | ![pt = PivotTable[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: New Mothers\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: New Mothers-Input",
AutoDelete->True]\)], {"smoked" -> (Length[#smoke] &)}, "alcohol", "smoke", IncludeGroupAggregates -> True]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/1e7ccd6cccb679f4.png) | 
| Out[18]= |  | 
The resulting pivot table has a key column and therefore has row keys:
| In[19]:= | ![Keys[pt]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/2b9491e8d8fd013f.png) | 
| Out[19]= |  | 
Use RowKey and ExtendedKey to extract values from the pivot table:
| In[20]:= | ![allSmoked = pt[RowKey["All"], ExtendedKey["smoked", True]]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/58ca245f76fbda36.png) | 
| Out[20]= |  | 
| In[21]:= | ![allAlcohol = pt[RowKey[True], ExtendedKey["smoked", "All"]]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/0038b87b8af0b181.png) | 
| Out[21]= |  | 
| In[22]:= | ![allSmokedAndAlcohol = pt[RowKey[True], ExtendedKey["smoked", True]]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/013dfdca64bad392.png) | 
| Out[22]= |  | 
Create Venn diagram:
| In[23]:= | ![smoke = Disk[{0.5, 0}];
alcohol = Disk[{-0.5, 0}];
subsets = Subsets[{smoke, alcohol}, {1, 2}];](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/0e70c49deb9f7e71.png) | 
| In[24]:= | ![subsetscolors = Function[cd, {cd[1], cd[2], Blend[{cd[1], cd[2]}]}][ColorData[93]];
labels = (Placed[Style[Column[#, Alignment -> Center], 16, Bold], Center, Background -> None] & /@ {{"smoke", allSmoked}, {"alcohol", allAlcohol}, {"alcohol", "and", "smoke",
       allSmokedAndAlcohol}});](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/09dd699d4621052a.png) | 
| In[25]:= | ![RegionPlot[
 Evaluate[
  DiscretizeRegion[
     RegionDifference[BooleanRegion[And, #], BooleanRegion[Or, Complement[{smoke, alcohol, EmptyRegion[2]}, #]]]] & /@ subsets], PlotLabels -> labels, PlotStyle -> subsetscolors, BoundaryStyle -> Directive[White, Thickness[.0085]], Frame -> False, PerformanceGoal -> "Speed", AspectRatio -> .7]](https://www.wolframcloud.com/obj/resourcesystem/images/f87/f87ed6d9-d3ab-49df-a01f-6635c06ba3dc/54b193384ec55bf3.png) | 
| Out[25]= |  | 
Gosia Konwerska, "Sample Tabular Data: New Mothers" from the Wolfram Data Repository (2025)