Hi
Apologies as this is quite simple but I haven't been able to address it. I am transposing a long dataset into wide and I have been able to do so but in the process, lost 3 subjects. Because an ID value occurs twice in the same BY group, SAS is omitting the subject altogether so that in total i have 292 subjects (rather than 295 in total). "Error: The ID value "var_Aspartate_Aminotransferase__" occurs twice in the same BY group...3 BY groups omitted due to earlier errors."(i think it's because sas does not recognise the full name as it exceeds the character limit as one is actually serum and the other plasma).
I tried to modify by dataset and command "if labname=Aspartate_Aminotransferase__Plas then remove;" but the log comes up as "Variable Aspartate_Aminotransferase__Plas is uninitialized."
I would like to take out the culprit duplicated aspartate_aminotransferase variable before doing my proc transpose command and essentially keep all 295 subjects if it means either deleting the whole variable (as i dont need it in my final analyses) or being able to pick out how to delete the offending 'duplication'.
I have copied in the long data format of 2 of the subjects with duplicated aspartate_aminotransferase that led to it being omitted.
Thanks,
subject | labname | labvalue |
E03 | Albumin (Plasma) | 47 |
E03 | Albumin (Serum) | 43.3 |
E03 | Alkaline Phosphatase (Plasma) | 80 |
E03 | Alkaline Phosphatase (Serum) | 74 |
E03 | Aspartate Aminotransferase (Plasma) | 22 |
E03 | Aspartate Aminotransferase (Serum) | 31 |
E03 | Basophils, Particle Concentration (Blood) | 0.01 |
E03 | Bilirubin, Total (Plasma) | 9 |
E03 | Bilirubin, Total (Serum) | 13.68 |
E03 | Calcium (Plasma) | 2.39 |
E03 | Calcium (Serum) | 2.4451 |
E03 | Carbohydrate Antigen 125 (Serum) | 17.8 |
E03 | Creatinine (Plasma) | 58 |
E03 | Creatinine (Serum) | 70.72 |
E03 | Eosinophils, Particle Conc. (Blood) | 0.08 |
E03 | Erythrocytes, Mean Cell Volume (Blood) | 101 |
E03 | Erythrocytes, Particle Concentration (Blood) | 3.56 |
E03 | Gamma-Glutamyltransferase (Plasma) | 13 |
E03 | Gamma-Glutamyltransferase (Serum) | 15 |
E03 | Hemoglobin (Blood) | 122 |
E03 | Lactate Dehydrogenase (Plasma) | 164 |
E03 | Lactate Dehydrogenase (Serum) | 399 |
E03 | Leucocytes, Particle Concentration (Blood) | 3.6 |
E03 | Lymphocytes, Particle Concentration (Blood) | 0.97 |
E03 | Magnesium (Plasma) | 0.93 |
E03 | Magnesium (Serum) | 0.94622 |
E04 | Albumin (Plasma) | 44 |
E04 | Albumin (Serum) | 36 |
E04 | Alkaline Phosphatase (Plasma) | 57 |
E04 | Alkaline Phosphatase (Serum) | 58 |
E04 | Aspartate Aminotransferase (Plasma) | 25 |
E04 | Aspartate Aminotransferase (Serum) | 22 |
E04 | Basophils, Particle Concentration (Blood) | 0.03 |
E04 | Bilirubin, Total (Plasma) | 5 |
E04 | Bilirubin, Total (Serum) | 7.866 |
E04 | Calcium (Plasma) | 2.38 |
E04 | Calcium (Serum) | 2.2954 |
E04 | Carbohydrate Antigen 125 (Serum) | 15.4 |
E04 | Creatinine (Plasma) | 67 |
E04 | Creatinine (Serum) | 67.184 |
E04 | Eosinophils, Particle Conc. (Blood) | 0.16 |
E04 | Erythrocytes, Mean Cell Volume (Blood) | 94 |
E04 | Erythrocytes, Particle Concentration (Blood) | 3.72 |
E04 | Gamma-Glutamyltransferase (Plasma) | 24 |
E04 | Gamma-Glutamyltransferase (Serum) | 30 |
E04 | Hemoglobin (Blood) | 117 |
E04 | Lactate Dehydrogenase (Plasma) | 211 |
E04 | Lactate Dehydrogenase (Serum) | 212 |
E04 | Leucocytes, Particle Concentration (Blood) | 5 |
E04 | Lymphocytes, Particle Concentration (Blood) | 1.46 |
E04 | Magnesium (Plasma) | 0.75 |
E04 | Magnesium (Serum) | 0.777546 |
I tried to modify by dataset and command "if labname=Aspartate_Aminotransferase__Plas then remove;" but the log comes up as "Variable Aspartate_Aminotransferase__Plas is uninitialized."
I suspect you should be doing this: if labname="Aspartate Aminotransferase (Plasma)" then remove;
I tried to modify by dataset and command "if labname=Aspartate_Aminotransferase__Plas then remove;" but the log comes up as "Variable Aspartate_Aminotransferase__Plas is uninitialized."
I suspect you should be doing this: if labname="Aspartate Aminotransferase (Plasma)" then remove;
When you transpose the new variables will be created with SAS Naming convention (32 characters only), so if you have values then they will be truncated. Check the second reply here, which is something similar to your.
thanks for the help everyone
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.