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

Hello, I am new to SAS and I am working with a large microarray data set. I need to transpose my long data to wide format. Example of my data is shown below with what the wide format should be.

 

Data MAlong

IDSNPsGenotype
23456rs1234CC
23456rs1235CC
23456rs1236TT
23456rs1237AA
23456rs1238TT
23456rs1239GG
23456rs1240GG
23456rs1241TT
23456rs1242CC
23456rs1243AA
17235rs1234TT
17235rs1235GG
17235rs1236TT
17235rs1237CC
17235rs1238AA
17235rs1239AA
17235rs1240AG
17235rs1241GG
17235rs1242GG
17235rs1243TC
25342rs1234AA
25342rs1235AG
25342rs1236AA
25342rs1237AG
25342rs1238TT
25342rs1239CC
25342rs1240--
25342rs1241GG
25342rs1242GG
25342rs1243GG

 

Data MAwide

IDrs1234rs1235rs1236rs1237rs1238rs1239rs1240rs1241rs1242rs1243
23456CCCCTTAATTGGGGTTCCAA
17235TTGGTTCCAAAAAGGGGGTC
25342AAAGAAAGTTCC--GGGGGG

 

I am getting an error from my transpose code and figured that a macro may be needed in the code to do what I am looking for. An example of one of my code is shown below and I have modified with multiple ways

 

PROC TRANSPOSE data = MAlong out= MAWide ;
by ID;
var Genotype ;
ID SNPs;
run;

 

Can someone help me fix this code?

 

Thanks,

Joy

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

The only thing I see is that the data is not sorted in ascending order, so you need the NOTSORTED option:

PROC TRANSPOSE data = MAlong out= MAWide ;
by ID notsorted;
var Genotype;
ID SNPs;
run;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

The only thing I see is that the data is not sorted in ascending order, so you need the NOTSORTED option:

PROC TRANSPOSE data = MAlong out= MAWide ;
by ID notsorted;
var Genotype;
ID SNPs;
run;
joa2
Calcite | Level 5
Thanks, that seems to do the trick.

Best,
Joy

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1024 views
  • 1 like
  • 2 in conversation