Another way is to read the data as desired in the first case:
proc format library=work;
invalue $nomiss
' ','.'='-9'
other=_same_;
invalue nomiss
' ','.'=-9
other=_same_;
run;
data have;
length name $ 10 gen $ 6;
informat id nomiss. name $nomiss. gen $nomiss. PROCHI DATE TC HDL LDL Ttg nomiss.;
input id name$ gen$ PROCHI DATE TC HDL LDL Ttg;
datalines;
1 ram male 1 1.1 8.0 3.0 1.45 1
2 mohan male 1 1.1 8.5 2.9 1.24 .
3 shyam . 2 2.1 6.8 3.1 2.23 2
4 radha female 2 2.1 7.2 3.8 3.80 .
5 gita female 2 2.1 . 2.7 3.45 3
6 sita . 2 3.1 8.9 6.8 4.56 2
7 ranu female 3 2.1 7.5 5.9 1.83 5
8 tina female 3 2.1 3.6 2.8 1.23 8
9 shan male 4 8.1 2.8 1.1 1.67 9
;
run;
This requires a little more from you to set the lengths of the string variables with either a Length or Attrib statement to prevent the character informat from setting the length to 2. I did not attempt to set a default length for the $nomiss informat as I have no idea what range of values you might be attempting to read.
... View more