BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lavienrose1
Calcite | Level 5

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,

 

subjectlabnamelabvalue
E03Albumin (Plasma)47
E03Albumin (Serum)43.3
E03Alkaline Phosphatase (Plasma)80
E03Alkaline Phosphatase (Serum)74
E03Aspartate Aminotransferase (Plasma)22
E03Aspartate Aminotransferase (Serum)31
E03Basophils, Particle Concentration (Blood)0.01
E03Bilirubin, Total (Plasma)9
E03Bilirubin, Total (Serum)13.68
E03Calcium (Plasma)2.39
E03Calcium (Serum)2.4451
E03Carbohydrate Antigen 125 (Serum)17.8
E03Creatinine (Plasma)58
E03Creatinine (Serum)70.72
E03Eosinophils, Particle Conc. (Blood)0.08
E03Erythrocytes, Mean Cell Volume (Blood)101
E03Erythrocytes, Particle Concentration (Blood)3.56
E03Gamma-Glutamyltransferase (Plasma)13
E03Gamma-Glutamyltransferase (Serum)15
E03Hemoglobin (Blood)122
E03Lactate Dehydrogenase (Plasma)164
E03Lactate Dehydrogenase (Serum)399
E03Leucocytes, Particle Concentration (Blood)3.6
E03Lymphocytes, Particle Concentration (Blood)0.97
E03Magnesium (Plasma)0.93
E03Magnesium (Serum)0.94622
E04Albumin (Plasma)44
E04Albumin (Serum)36
E04Alkaline Phosphatase (Plasma)57
E04Alkaline Phosphatase (Serum)58
E04Aspartate Aminotransferase (Plasma)25
E04Aspartate Aminotransferase (Serum)22
E04Basophils, Particle Concentration (Blood)0.03
E04Bilirubin, Total (Plasma)5
E04Bilirubin, Total (Serum)7.866
E04Calcium (Plasma)2.38
E04Calcium (Serum)2.2954
E04Carbohydrate Antigen 125 (Serum)15.4
E04Creatinine (Plasma)67
E04Creatinine (Serum)67.184
E04Eosinophils, Particle Conc. (Blood)0.16
E04Erythrocytes, Mean Cell Volume (Blood)94
E04Erythrocytes, Particle Concentration (Blood)3.72
E04Gamma-Glutamyltransferase (Plasma)24
E04Gamma-Glutamyltransferase (Serum)30
E04Hemoglobin (Blood)117
E04Lactate Dehydrogenase (Plasma)211
E04Lactate Dehydrogenase (Serum)212
E04Leucocytes, Particle Concentration (Blood)5
E04Lymphocytes, Particle Concentration (Blood)1.46
E04Magnesium (Plasma)0.75
E04Magnesium (Serum)0.777546
1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
Opal | Level 21

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;

View solution in original post

4 REPLIES 4
SASKiwi
Opal | Level 21

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;

SuryaKiran
Meteorite | Level 14

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.

https://communities.sas.com/t5/SAS-Procedures/How-do-I-transpose-my-data-from-long-to-wide/m-p/45497...

 

Thanks,
Suryakiran
Reeza
Super User
Are you transposing from long to wide or wide to long? If long to wide you can fix the record with duplicates by manually recoding it using IF/THEN. If you’re going from wide to long you’d do it with a RENAME statement.
lavienrose1
Calcite | Level 5

thanks for the help everyone

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 735 views
  • 2 likes
  • 4 in conversation