Skip to content

Commit

Permalink
Fix #53
Browse files Browse the repository at this point in the history
For numeric values, we only need to increment $nominalIdx by 1. With date having width of 20, Utils::widthToOcts($var->width) returns 3 and $nominalIndex is no longer correctly calculated as it shifts subsequent variables too far.
  • Loading branch information
sakalauskas authored Dec 16, 2020
1 parent fb5ccb6 commit ec2682d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Sav/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ public function write($data)
$this->data->matrix[$case][$idx] = $value;
}

$nominalIdx += Utils::widthToOcts($var->width);
if (Variable::isNumberFormat($var->format)) {
$nominalIdx += 1;
} else {
$nominalIdx += Utils::widthToOcts($var->width);
}
}

$this->header->nominalCaseSize = $nominalIdx;
Expand Down

0 comments on commit ec2682d

Please sign in to comment.