Hi again Perl gurus.
I've used the following code which produces the output I want where patientid is the key and each file has three values so the output looks like:
Patientid Var1File1 Var2File1 Var3File1 Var1File2......
1200 val val val val
1203 val val val val
1204 val val val val
Now I want to use my following code to insert patientid key values where there was a consecutive missing patientid. Like
Patientid Var1File1 Var2File1 Var3File1 Var1File2....
1200 val val val val
1201 nil nil nil nil
1202 nil nil nil nil
1203 val val val val
1204 val val val val
This is the exact code of mine that worked on producing my first dataset correctly. Now I just don't know how to add consecutive missing keys.... If any gurus know, could you please let me know? THANKya
foreach $id (sort(keys(%megahash))) {
my %patient_data = %{$megahash{$id}};
print OUTFILE "$id";
foreach my $file (sort(@files)) {
print OUTFILE ",";
if(exists $patient_data{$file}) {
print OUTFILE join(",", @{$patient_data{$file}});
} else {
print OUTFILE "nil,nil,nil";
}
}
print OUTFILE"\n";
}
I've used the following code which produces the output I want where patientid is the key and each file has three values so the output looks like:
Patientid Var1File1 Var2File1 Var3File1 Var1File2......
1200 val val val val
1203 val val val val
1204 val val val val
Now I want to use my following code to insert patientid key values where there was a consecutive missing patientid. Like
Patientid Var1File1 Var2File1 Var3File1 Var1File2....
1200 val val val val
1201 nil nil nil nil
1202 nil nil nil nil
1203 val val val val
1204 val val val val
This is the exact code of mine that worked on producing my first dataset correctly. Now I just don't know how to add consecutive missing keys.... If any gurus know, could you please let me know? THANKya
foreach $id (sort(keys(%megahash))) {
my %patient_data = %{$megahash{$id}};
print OUTFILE "$id";
foreach my $file (sort(@files)) {
print OUTFILE ",";
if(exists $patient_data{$file}) {
print OUTFILE join(",", @{$patient_data{$file}});
} else {
print OUTFILE "nil,nil,nil";
}
}
print OUTFILE"\n";
}