Not able to run from SPSS software can you guide the steps
cd "/home/daytona/workspace/attachments/0a20a44c-dc26-48cb-97fd-2ac26319ee6a/" && python3 -c " import openpyxl wb = openpyxl.load_workbook('PP_Study_427_Completed (2).xlsx', read_only=True) print('Sheets:', wb.sheetnames) for sheet in wb.sheetnames: ws = wb[sheet] print(f'\nSheet: {sheet} | Rows: {ws.max_row} | Cols: {ws.max_column}') # Print first 5 rows for i, row in enumerate(ws.iter_rows(values_only=True)): if i >= 5: break print(row) "
cd "/home/daytona/workspace/attachments/0a20a44c-dc26-48cb-97fd-2ac26319ee6a/" && python3 -c " import openpyxl wb = openpyxl.load_workbook('PP_Study_427_Completed (2).xlsx', read_only=True) # Read SPSS Syntax sheet fully ws = wb['SPSS Syntax'] print('=== SPSS SYNTAX SHEET ===') for i, row in enumerate(ws.iter_rows(values_only=True)): if row[0] is not None: print(f'Row {i+1}: {row[0]}') if i > 80: print('...truncated...') break "
PP_Study_427_Data.csvPP_Study_427_Data.csvAlternative: Import directly from Excel File > Import Data > Excel > select the .xlsx file > Sheet = "Data Entry" > tick "Read variable names from first row" > set Header Row = 3 > Data starts at row 4
| Step | What it sets up |
|---|---|
| Step 2 | Variable Labels (readable names for all 39 variables) |
| Step 3 | Value Labels (e.g., 1=Yes, 0=No, 1=Urban, 2=Semiurban) |
| Step 4 | Missing Values (9 = missing for binary fields, 99 = unknown for age/numeric fields) |
| Step 5 | Descriptive statistics - frequencies for categorical variables |
| Step 6 | Descriptives for continuous variables (Age, BMI, Age_Menarche, etc.) |
| Later steps | Cross-tabs, Chi-square tests, logistic regression, etc. |
| Problem | Fix |
|---|---|
| "Variable not found" error | Your column header names in SPSS don't match the syntax. Check that you imported row 3 as the header row (not row 1 or 2) |
| Data imports but all values are blank | The Excel formula cells (like Residence auto-filled from school name) didn't export as values. Go back to Excel, copy the Residence column, Paste Special > Values only, then re-export as CSV |
| BMI column shows formula text | Same fix - paste BMI column as values before exporting |
| "Unexpected end of command" syntax error | Make sure the full syntax was copied, including the final period (.) at the end of each block |
| SPSS opens file but shows garbage variable names | You imported from the wrong row. Re-import with header row set to 3 |
| Numeric variables imported as String | In the Variable View tab, change the Type from "String" to "Numeric" for variables like Age, BMI, Income, etc. |
Am using ibm spssstaistics data editor version 21 can youbshow it's steps
PP_Study_427_Completed (2).xlsx
2. Click the Data Entry tab
3. Select the entire sheet: press Ctrl + A
4. Copy: Ctrl + C
5. Right-click cell A1 > Paste Special > click the Values icon (123 icon)
6. Now go to File > Save As > choose format CSV (Comma delimited) (.csv) > name it PP_Study_Data.csv > click Save > click Yes on the warningStep 1 of 6
- "Does your text file match a predefined format?" → select No
- Click Next
Step 2 of 6
- "How are your variables arranged?" → select Delimited
- "Are variable names included at the top of your file?" → select Yes
- "Which line number begins your first case of data?" → type 4
- Click Next
Step 3 of 6
- "Which delimiters appear between variables?" → tick Comma
- Untick Tab, Space, Semicolon if they are ticked
- "What is the text qualifier?" → select Double quote ( " )
- Click Next
Step 4 of 6
- You will see a preview of your variables
- Check that column names look correct (ID, Age, Grade, Residence, etc.)
- Click Next
Step 5 of 6
- For each variable, you can set the data type
- Leave most as Numeric
- For text columns (Child_Name, Illness_Details, Doctor_Details, S_Health_Notes) - set those to String
- Click Next
Step 6 of 6
- "Would you like to save this file format for future use?" → select No
- Click Finish
PP_Study_427.sav| Column | What to check |
|---|---|
| Type | Should be Numeric for all number columns; String for name/details columns |
| Decimals | Set to 0 for ID, Age, Grade, all Yes/No fields |
| Missing | Enter 9 for binary (Yes/No) variables; enter 99 for age/numeric variables |
| Measure | Set to Scale for Age, BMI, Hrs_Outdoors; Ordinal for Education, Income; Nominal for Residence, Family_Type |
| What you see | Fix |
|---|---|
| All data in one column | You chose wrong delimiter - re-import, tick Comma only |
| Variable names are VAR001, VAR002 | Re-import, set "Variable names at top" = Yes and start data at line 4 |
| Numbers showing as dots (.) | Missing value - this is normal for empty cells |
| Syntax runs but shows errors in red | Copy only from row 3 of SPSS Syntax tab (skip row 1 which is a title) |
| "End of file" error | Your CSV has blank rows at the bottom - that is fine, ignore it |
Got this error in spss
PP_Clean.csvPP_Clean.csv| Wizard Screen | Setting |
|---|---|
| Step 1 of 6 | Predefined format? → No |
| Step 2 of 6 | Delimited → Yes / Variable names at top → Yes / First case on line → 2 |
| Step 3 of 6 | Delimiter → tick Comma only |
| Step 4 of 6 | Check preview - you should now see ID, Age, Grade, Residence... as column headers |
| Step 5 of 6 | Leave as default |
| Step 6 of 6 | Click Finish |
| ID | Age | Grade | Residence | Family_Type | ... |
|---|---|---|---|---|---|
| 1 | 13 | 8 | 1 | 1 | ... |
| 2 | 14 | 9 | 1 | 1 | ... |
PRECOCIOUSPUBERT (SPSS truncated it to 16 characters).Is this correct
(Optiol)","P2. Age(10-15 yrs)","P3. Grade/Standard(6,7,8,9)","P4. School me1, 13, 8, 1, 1, 4, 5... (actual numbers)PP_Clean.csv > Save > YesPP_Clean.csv| Step | Setting |
|---|---|
| Step 2 of 6 | Variable names at top of file → Yes / First case begins on line → 2 |
| Step 3 of 6 (this screen) | First case of data begins on line → 2 / Each line represents a case → Yes / All of the cases → Yes |
Column and row have too much length is is it possible to cut short it's length in variable and get a clutter free SPSS output without error.please give CSV file tailored for SPSS
cd "/home/daytona/workspace/attachments/0a20a44c-dc26-48cb-97fd-2ac26319ee6a/" && python3 -c " import openpyxl wb = openpyxl.load_workbook('PP_Study_427_Completed (2).xlsx', read_only=True) ws = wb['Data Entry'] rows = list(ws.iter_rows(values_only=True)) print('Row 1:', rows[0]) print('Row 2:', rows[1]) print('Row 3 (headers):', rows[2]) print('Row 4 (data):', rows[3]) print('Row 5 (data):', rows[4]) print('Total rows:', len(rows)) print('Total cols:', len(rows[2])) "
python3 << 'EOF' import openpyxl import csv import re wb = openpyxl.load_workbook('/home/daytona/workspace/attachments/0a20a44c-dc26-48cb-97fd-2ac26319ee6a/PP_Study_427_Completed (2).xlsx', read_only=True) ws = wb['Data Entry'] rows = list(ws.iter_rows(values_only=True)) # SPSS-safe short variable names (max 8 chars for SPSS 21, all unique, no spaces/special chars) # Mapping: col index -> SPSS variable name spss_vars = [ 'ID', # 0 'Child_Name', # 1 - P1 child name (optional, string) 'Age', # 2 - P2 age 'Grade', # 3 - P3 grade 'School', # 4 - P4 school name (string) 'Residence', # 5 - P5 residence (1=Urban 2=Semiurban) - formula, compute from school 'Fam_Type', # 6 - P6 family type 'Dad_Edu', # 7 - P7a father education 'Mom_Edu', # 8 - P7b mother education 'Income', # 9 - P8 income 'Chr_Ill', # 10 - P9 chronic illness 'Ill_Detail', # 11 - P9 illness details (string) 'Fam_Pub', # 12 - P10 family hx puberty 'Medic', # 13 - P11 medications 'Med_Detail', # 14 - P11 medication details (string) 'Age_Menar', # 15 - P12 age at menarche 'Diet_Home', # 16 - P13a homecooked 'Diet_Fast', # 17 - P13b fast food 'Diet_Proc', # 18 - P13c processed 'Diet_Prot', # 19 - P13d high protein 'Diet_Trad', # 20 - P13e traditional Kerala 'Hrs_Out', # 21 - P14 hours outdoors 'Scr_Time_P', # 22 - P15 screen time parent 'Pestic', # 23 - P16 pesticide exposure 'Pest_Det', # 24 - P16 pesticide details (string) 'Age_Pub', # 25 - P17 age puberty signs 'Doc_Conf', # 26 - P18 doctor confirmed 'Doc_Det', # 27 - P18 doctor details (string) 'P_Consent', # 28 - P19 parent consent 'S_Out_Play', # 29 - S1 outdoor play 'S_Out_Hrs', # 30 - S1 outdoor hours 'S_Scr_Time', # 31 - S2 screen time student 'S_Body_Chg', # 32 - S3 body changes 'S_Age_Body', # 33 - S3 age body changes 'S_Menarche', # 34 - S4 first period 'S_Age_Men', # 35 - S4 age first period 'S_Health', # 36 - S5 health notes (string) 'S_Assent', # 37 - S6 student assent 'Height', # 38 - height cm 'Weight', # 39 - weight kg 'BMI', # 40 - BMI (auto) ] # String columns (will be kept as text, others forced to numeric) string_cols = {1, 4, 11, 14, 24, 27, 36} # For Residence (col 5): formula - derive from School name (col 4) # Irumbuzhi = 2 (Semiurban), others = 1 (Urban) # For BMI (col 40): formula - compute from Height/Weight def compute_residence(school_val): if school_val is None or school_val == '': return '' school_str = str(school_val) if 'Irumbuzhi' in school_str or 'irumbuzhi' in school_str: return 2 return 1 def compute_bmi(height, weight): try: h = float(height) w = float(weight) if h > 0 and w > 0: return round(w / (h/100)**2, 1) except: pass return '' import os os.makedirs('/home/daytona/workspace/pp-study-spss/', exist_ok=True) output_path = '/home/daytona/workspace/pp-study-spss/PP_Study_SPSS_Ready.csv' data_rows = rows[3:] # skip rows 0,1,2 (titles + headers) written = 0 skipped = 0 with open(output_path, 'w', newline='', encoding='utf-8') as f: writer = csv.writer(f) # Write single clean header row writer.writerow(spss_vars) for row in data_rows: # Skip completely empty rows if all(v is None or v == '' for v in row): skipped += 1 continue # Skip rows where ID is missing or not a number if row[0] is None or row[0] == '': skipped += 1 continue clean_row = [] for i, val in enumerate(row): if i == 5: # Residence - compute from school name clean_row.append(compute_residence(row[4])) elif i == 40: # BMI - compute from height/weight h = row[38] if len(row) > 38 else None w = row[39] if len(row) > 39 else None clean_row.append(compute_bmi(h, w)) elif i in string_cols: # String columns - clean up newlines, keep as text if val is None: clean_row.append('') else: clean_row.append(str(val).replace('\n', ' ').strip()) else: # Numeric columns if val is None or val == '': clean_row.append('') elif isinstance(val, str): # Try to extract number from formula or text if val.startswith('='): clean_row.append('') # formula with no resolved value else: # Try to parse as number try: clean_row.append(float(val)) except: clean_row.append(val.replace('\n', ' ').strip()) else: clean_row.append(val) writer.writerow(clean_row) written += 1 print(f'Done! Written: {written} data rows, Skipped: {skipped} empty rows') print(f'Output: {output_path}') # Verify first few rows with open(output_path, 'r') as f: lines = f.readlines() print(f'Total lines in CSV: {len(lines)}') print('Header:', lines[0][:200]) print('Row 1:', lines[1][:200]) print('Row 2:', lines[2][:200]) EOF
PP Study SPSS Ready
CSV File · CSV
| Problem | Fix Applied |
|---|---|
| 3 title rows before real data | Removed - now Row 1 = headers, Row 2 = first patient |
| Long messy column names with line breaks | Replaced with short clean SPSS names (see table below) |
| Formula cells (Residence, BMI) | Computed to actual values - Residence=1/2, BMI=17.1 etc. |
| Empty rows (rows 428-505) | Removed - only 427 real participant rows kept |
| Mixed data types causing errors | All numeric columns are clean numbers, text columns are clean strings |
| SPSS Name | Original Question | Values |
|---|---|---|
| ID | Participant number | 1-427 |
| Child_Name | P1. Child name | Text |
| Age | P2. Age | 10-15 |
| Grade | P3. Grade | 6,7,8,9 |
| School | P4. School name | Text |
| Residence | P5. Residence | 1=Urban, 2=Semiurban |
| Fam_Type | P6. Family type | 1=Nuclear, 2=Joint |
| Dad_Edu | P7a. Father education | 1-5 |
| Mom_Edu | P7b. Mother education | 1-5 |
| Income | P8. Monthly income | 1-4 |
| Chr_Ill | P9. Chronic illness | 1=Yes, 0=No |
| Ill_Detail | P9. Illness details | Text |
| Fam_Pub | P10. Family hx puberty | 1=Yes, 0=No |
| Medic | P11. Medications | 1=Yes, 0=No |
| Med_Detail | P11. Medication details | Text |
| Age_Menar | P12. Age at menarche | Years (99=Not yet) |
| Diet_Home | P13a. Homecooked meals | 1=Yes, 0=No |
| Diet_Fast | P13b. Fast food >3x/wk | 1=Yes, 0=No |
| Diet_Proc | P13c. Processed foods | 1=Yes, 0=No |
| Diet_Prot | P13d. High protein | 1=Yes, 0=No |
| Diet_Trad | P13e. Traditional Kerala diet | 1=Yes, 0=No |
| Hrs_Out | P14. Hours outdoors/day | Number |
| Scr_Time_P | P15. Screen time (parent) | 1=Yes, 0=No |
| Pestic | P16. Pesticide exposure | 1=Yes, 0=No |
| Pest_Det | P16. Pesticide details | Text |
| Age_Pub | P17. Age puberty signs | Years (99=Unknown) |
| Doc_Conf | P18. Doctor confirmed | 1=Yes, 0=No |
| Doc_Det | P18. Doctor details | Text |
| P_Consent | P19. Parent consent | 1=Yes, 0=No |
| S_Out_Play | S1. Student outdoor play | 1=Yes, 0=No |
| S_Out_Hrs | S1. Student outdoor hours | Number |
| S_Scr_Time | S2. Student screen time | 1=Yes, 0=No |
| S_Body_Chg | S3. Body changes noticed | 1=Yes, 0=No |
| S_Age_Body | S3. Age at body changes | Years (99=DK) |
| S_Menarche | S4. First period | 1=Yes, 0=No |
| S_Age_Men | S4. Age at first period | Years |
| S_Health | S5. Health notes | Text |
| S_Assent | S6. Student assent | 1=Yes, 0=No |
| Height | Height | cm |
| Weight | Weight | kg |
| BMI | BMI (calculated) | Number |
PP_Study_SPSS_Ready.csvRemove long school name from CSV file just give numbers 1,2 or 3 .fill unfilled space as 99 in age columns not filled
python3 << 'EOF' import openpyxl import csv import os wb = openpyxl.load_workbook('/home/daytona/workspace/attachments/0a20a44c-dc26-48cb-97fd-2ac26319ee6a/PP_Study_427_Completed (2).xlsx', read_only=True) ws = wb['Data Entry'] rows = list(ws.iter_rows(values_only=True)) # First, let's see all unique school names to map them correctly schools = set() for row in rows[3:]: if row[0] is not None and row[4] is not None: schools.add(str(row[4])) print("Unique school values:") for s in sorted(schools): print(repr(s)) EOF
python3 << 'EOF' import openpyxl import csv wb = openpyxl.load_workbook('/home/daytona/workspace/attachments/0a20a44c-dc26-48cb-97fd-2ac26319ee6a/PP_Study_427_Completed (2).xlsx', read_only=True) ws = wb['Data Entry'] rows = list(ws.iter_rows(values_only=True)) # Age columns that should use 99 for missing (col index) # Age_Menar=15, Age_Pub=25, S_Age_Body=33, S_Age_Men=35, S_Out_Hrs=30 age_cols = {15, 25, 33, 35} # Numeric cols that should use 99 for missing (not binary 0/1) # Also S_Out_Hrs (col 30) and Hrs_Out (col 21) - use 99 numeric_99_cols = {15, 21, 25, 30, 33, 35, 38, 39, 40} # age + hours + height/weight/BMI # Binary cols (0/1) - leave blank as blank (or 9 for missing, but user said 99 for age only) # We'll fill age-type columns with 99, leave others blank # School name -> number mapping (extract leading digit) def school_to_num(val): if val is None or val == '': return 9 # unknown school s = str(val).strip() # Extract leading number if s.startswith('1'): return 1 elif s.startswith('2'): return 2 elif s.startswith('3'): return 3 return 9 def compute_residence(school_val): if school_val is None or school_val == '': return 9 s = str(school_val) if 'Irumbuzhi' in s or 'irumbuzhi' in s: return 2 return 1 def compute_bmi(height, weight): try: h = float(height) w = float(weight) if h > 0 and w > 0: return round(w / (h/100)**2, 1) except: pass return 99 spss_vars = [ 'ID','Child_Name','Age','Grade','School','Residence','Fam_Type', 'Dad_Edu','Mom_Edu','Income','Chr_Ill','Ill_Detail','Fam_Pub', 'Medic','Med_Detail','Age_Menar','Diet_Home','Diet_Fast','Diet_Proc', 'Diet_Prot','Diet_Trad','Hrs_Out','Scr_Time_P','Pestic','Pest_Det', 'Age_Pub','Doc_Conf','Doc_Det','P_Consent','S_Out_Play','S_Out_Hrs', 'S_Scr_Time','S_Body_Chg','S_Age_Body','S_Menarche','S_Age_Men', 'S_Health','S_Assent','Height','Weight','BMI' ] string_cols = {1, 4, 11, 14, 24, 27, 36} # col 4 (School) now numeric, remove it string_cols = {1, 11, 14, 24, 27, 36} data_rows = rows[3:] output_path = '/home/daytona/workspace/pp-study-spss/PP_Study_SPSS_Ready.csv' written = 0 with open(output_path, 'w', newline='', encoding='utf-8') as f: writer = csv.writer(f) writer.writerow(spss_vars) for row in data_rows: if all(v is None or v == '' for v in row): continue if row[0] is None or row[0] == '': continue clean_row = [] for i, val in enumerate(row): # --- Special computed columns --- if i == 4: # School: number only clean_row.append(school_to_num(val)) continue if i == 5: # Residence: compute from school name clean_row.append(compute_residence(row[4])) continue if i == 40: # BMI: compute from height/weight h = row[38] if len(row) > 38 else None w = row[39] if len(row) > 39 else None clean_row.append(compute_bmi(h, w)) continue # --- String columns --- if i in string_cols: if val is None: clean_row.append('') else: clean_row.append(str(val).replace('\n', ' ').strip()) continue # --- Numeric columns --- if val is None or val == '': # Fill age/numeric cols with 99, binary cols leave blank if i in numeric_99_cols: clean_row.append(99) else: clean_row.append('') continue if isinstance(val, str): if val.startswith('='): # Unresolved formula if i in numeric_99_cols: clean_row.append(99) else: clean_row.append('') else: try: clean_row.append(float(val)) except: clean_row.append(val.replace('\n', ' ').strip()) continue clean_row.append(val) writer.writerow(clean_row) written += 1 print(f"Written: {written} rows") # Quick verification with open(output_path) as f: lines = f.readlines() print(f"Total lines: {len(lines)}") print("Header:", lines[0]) print("Row1:", lines[1]) print("Row2:", lines[2]) # Check for any remaining long school names school_vals = set() for line in lines[1:]: parts = line.split(',') if len(parts) > 4: school_vals.add(parts[4]) print("\nUnique School values in CSV:", school_vals) # Check age column sample print("\nAge_Menar (col 15) sample:", [l.split(',')[15] for l in lines[1:6]]) print("Age_Pub (col 25) sample:", [l.split(',')[25] for l in lines[1:6]]) EOF
PP Study SPSS Ready
CSV File · CSV
| Number | School |
|---|---|
| 1 | Benchmark International School, Manjeri |
| 2 | GHSS Girls Manjeri |
| 3 | GHSS Irumbuzhi |
| Column | Meaning of 99 |
|---|---|
| Age_Menar | Menarche not yet occurred |
| Age_Pub | Age of puberty signs unknown |
| S_Age_Body | Age of body changes unknown |
| S_Age_Men | Age of first period unknown |
| Hrs_Out | Outdoor hours not recorded |
| S_Out_Hrs | Student outdoor hours not recorded |
| Height / Weight / BMI | Not measured |
PP_Study_SPSS_Ready.csvWhat about the syntax file I need to run in spss
python3 << 'EOF' import openpyxl wb = openpyxl.load_workbook('/home/daytona/workspace/attachments/0a20a44c-dc26-48cb-97fd-2ac26319ee6a/PP_Study_427_Completed (2).xlsx', read_only=True) ws = wb['SPSS Syntax'] print("=== FULL SPSS SYNTAX SHEET ===") for i, row in enumerate(ws.iter_rows(values_only=True)): if row[0] is not None: print(f"{i+1}: {row[0]}") EOF
~/pp-study-spss/PP_Study_427_Syntax.sps
* ================================================================
* PRECOCIOUS PUBERTY STUDY - COMPLETE SPSS SYNTAX
* Study: Prevalence of Precocious Puberty in School Girls
* Location: Manjeri & Anakkayam
* Variable names updated to match PP_Study_SPSS_Ready.csv
* ================================================================
* ----------------------------------------------------------------
* STEP 1: After importing PP_Study_SPSS_Ready.csv via
* File > Read Text Data, save as .sav then run this syntax
* ----------------------------------------------------------------
* ----------------------------------------------------------------
* STEP 2: Variable Labels
* ----------------------------------------------------------------
VARIABLE LABELS
ID 'Participant serial number'
Child_Name 'P1. Child name (optional)'
Age 'P2. Age of child (years)'
Grade 'P3. Grade or Standard'
School 'P4. School (1=Benchmark 2=GHSS Manjeri 3=GHSS Irumbuzhi)'
Residence 'P5. Residence type'
Fam_Type 'P6. Family type'
Dad_Edu 'P7a. Father education level'
Mom_Edu 'P7b. Mother education level'
Income 'P8. Monthly family income INR'
Chr_Ill 'P9. Chronic illness present'
Ill_Detail 'P9. Illness details'
Fam_Pub 'P10. Family history of early puberty'
Medic 'P11. Medications or hormones used'
Med_Detail 'P11. Medication details'
Age_Menar 'P12. Age at menarche (years, 99=not yet)'
Diet_Home 'P13a. Diet home-cooked meals'
Diet_Fast 'P13b. Diet fast food more than 3x per week'
Diet_Proc 'P13c. Diet processed foods'
Diet_Prot 'P13d. Diet high protein foods'
Diet_Trad 'P13e. Diet traditional Kerala'
Hrs_Out 'P14. Hours outdoors per day'
Scr_Time_P 'P15. Screen time more than 2 hrs/day (parent)'
Pestic 'P16. Pesticide or chemical exposure'
Pest_Det 'P16. Pesticide details'
Age_Pub 'P17. Age puberty signs first noticed (years)'
Doc_Conf 'P18. Doctor confirmed early puberty'
Doc_Det 'P18. Doctor confirmation details'
P_Consent 'P19. Parent or guardian consent'
S_Out_Play 'S1. Student plays outdoors daily'
S_Out_Hrs 'S1. Student outdoor hours per day'
S_Scr_Time 'S2. Student screen time more than 2 hrs/day'
S_Body_Chg 'S3. Student noticed body changes'
S_Age_Body 'S3. Student age at body changes (99=unknown)'
S_Menarche 'S4. Student had first menstrual period'
S_Age_Men 'S4. Student age at first period (99=not yet)'
S_Health 'S5. Student additional health notes'
S_Assent 'S6. Student assent'
Height 'Height in cm'
Weight 'Weight in kg'
BMI 'Body Mass Index (auto-calculated)'
.
* ----------------------------------------------------------------
* STEP 3: Value Labels
* ----------------------------------------------------------------
VALUE LABELS
School
1 'Benchmark Intl School Manjeri'
2 'GHSS Girls Manjeri'
3 'GHSS Irumbuzhi' /
Residence
1 'Urban'
2 'Semiurban' /
Fam_Type
1 'Nuclear'
2 'Joint' /
Dad_Edu Mom_Edu
1 'Illiterate'
2 'Primary'
3 'Secondary'
4 'Graduate'
5 'Post-graduate' /
Income
1 'Less than 10000'
2 '10000 to 30000'
3 '30000 to 50000'
4 'More than 50000' /
Chr_Ill Fam_Pub Medic Scr_Time_P Pestic
Doc_Conf P_Consent
Diet_Home Diet_Fast Diet_Proc Diet_Prot Diet_Trad
S_Out_Play S_Scr_Time S_Body_Chg S_Menarche S_Assent
1 'Yes'
0 'No' /
.
* ----------------------------------------------------------------
* STEP 4: Missing Values
* ----------------------------------------------------------------
MISSING VALUES
Age_Menar Age_Pub S_Age_Body S_Age_Men Hrs_Out S_Out_Hrs Height Weight BMI (99)
Residence Fam_Type Dad_Edu Mom_Edu Income
Chr_Ill Fam_Pub Medic
Diet_Home Diet_Fast Diet_Proc Diet_Prot Diet_Trad
Scr_Time_P Pestic Doc_Conf P_Consent
S_Out_Play S_Scr_Time S_Body_Chg S_Menarche S_Assent (9)
.
* ----------------------------------------------------------------
* STEP 5: Exclude non-consented participants
* ----------------------------------------------------------------
SELECT IF (P_Consent = 1 AND S_Assent = 1).
EXECUTE.
* ----------------------------------------------------------------
* STEP 6: DESCRIPTIVE STATISTICS - Categorical Variables
* ----------------------------------------------------------------
FREQUENCIES VARIABLES=School Residence Fam_Type Dad_Edu Mom_Edu Income
Chr_Ill Fam_Pub Medic Scr_Time_P Pestic
Doc_Conf Diet_Home Diet_Fast Diet_Proc
Diet_Prot Diet_Trad
S_Out_Play S_Scr_Time S_Body_Chg S_Menarche
/ORDER=ANALYSIS.
* ----------------------------------------------------------------
* STEP 7: DESCRIPTIVE STATISTICS - Continuous Variables
* ----------------------------------------------------------------
DESCRIPTIVES VARIABLES=Age Age_Menar Hrs_Out Age_Pub
S_Out_Hrs S_Age_Body S_Age_Men Height Weight BMI
/STATISTICS=MEAN STDDEV MIN MAX.
* ----------------------------------------------------------------
* STEP 8: CHI-SQUARE TESTS
* Risk factors vs Doctor-Confirmed Precocious Puberty
* ----------------------------------------------------------------
CROSSTABS
/TABLES=Residence Fam_Type Fam_Pub Medic
Scr_Time_P Pestic S_Scr_Time
Diet_Home Diet_Fast Diet_Proc Diet_Prot Diet_Trad
BY Doc_Conf
/FORMAT=AVALUE TABLES
/STATISTICS=CHISQ OR
/CELLS=COUNT ROW COLUMN EXPECTED
/COUNT ROUND CELL.
CROSSTABS
/TABLES=Income Mom_Edu Dad_Edu BY Doc_Conf
/STATISTICS=CHISQ
/CELLS=COUNT ROW COLUMN
/COUNT ROUND CELL.
* ----------------------------------------------------------------
* STEP 9: INDEPENDENT SAMPLES T-TEST
* Compare continuous variables between confirmed vs not confirmed
* ----------------------------------------------------------------
T-TEST GROUPS=Doc_Conf(0 1)
/MISSING=ANALYSIS
/VARIABLES=Age_Menar Hrs_Out S_Out_Hrs S_Age_Men BMI
/CRITERIA=CI(.95).
* ----------------------------------------------------------------
* STEP 10: BINARY LOGISTIC REGRESSION
* Outcome: Doc_Conf (1=Yes 0=No)
* ----------------------------------------------------------------
LOGISTIC REGRESSION VARIABLES Doc_Conf
/METHOD=ENTER Residence Fam_Type Mom_Edu Income
Fam_Pub Scr_Time_P Pestic
Diet_Fast Diet_Proc Hrs_Out BMI
/CLASSPLOT
/PRINT=GOODFIT ITER(1) CI(95)
/CRITERIA=PIN(.05) POUT(.10) ITERATE(20) CUT(.5).
* ----------------------------------------------------------------
* STEP 11: CORRELATION
* Age of puberty signs, menarche correlation
* ----------------------------------------------------------------
CORRELATIONS
/VARIABLES=Age_Pub Age_Menar S_Age_Men BMI Age
/PRINT=TWOTAIL NOSIG
/MISSING=PAIRWISE.
* ----------------------------------------------------------------
* STEP 12: SAVE CLEAN DATASET
* Change the path below to where you want to save your .sav file
* ----------------------------------------------------------------
SAVE OUTFILE='C:\Users\YourName\Desktop\PP_Study_427_Clean.sav'
/COMPRESSED.
* End of syntax.
PP Study 427 Syntax
SPS File · SPS
| Step | What It Does | SPSS Output |
|---|---|---|
| 2 | Variable Labels | Readable names appear in output |
| 3 | Value Labels | 0/1 shows as Yes/No, 1/2 shows as Urban/Semiurban etc. |
| 4 | Missing Values | 99 = missing for age/numeric; 9 = missing for Yes/No |
| 5 | Filter consent | Keeps only participants with consent + assent = 1 |
| 6 | Frequencies | Tables for all categorical variables |
| 7 | Descriptives | Mean, SD, Min, Max for age, BMI, hours etc. |
| 8 | Chi-Square | Risk factors vs Doctor-confirmed puberty |
| 9 | T-Test | Age, BMI, hours compared between confirmed vs not |
| 10 | Logistic Regression | Predicts precocious puberty from risk factors |
| 11 | Correlation | Age of puberty, menarche, BMI correlation |
| 12 | Save .sav | Saves clean dataset |
.savPP_Study_427_Syntax.spsSAVE OUTFILE='C:\Users\YourName\Desktop\PP_Study_427_Clean.sav'
Replace YourName with your actual Windows username