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

Hi there SAS friends:

 

My question is quite simple, and i will describe it here in this table:

 

i have this arrange:

 

Sample A B C D E F G H I J K L M N O P Q R
1 255 341 154 154 238 238 ? ? 253 253 134 134 117 125 116 116 ? ?
2 255 335 154 154 238 250 101 101 239 253 134 134 117 125 116 116 107 115
3 255 319 154 154 238 238 101 109 239 253 134 134 117 125 116 116 107 115
4 ? ? 154 154 238 260 101 109 239 253 134 134 125 125 116 116 107 115
5 255 255 154 154 238 238 101 109 239 253 132 134 117 125 116 116 107 115

 

and the arrange i'm looking for is:

 

  A/B C/D E/F G/H I/J K/L M/N O/P Q/R
1 255 154 238 ? 253 134 117 116 ?
1 341 154 238 ? 253 134 125 116 ?
2 255 154 238 101 239 134 117 116 107
2 335 154 250 101 253 134 125 116 115
3 255 154 238 101 239 134 117 116 107
3 319 154 238 109 253 134 125 116 115
4 ? 154 238 101 239 134 125 116 107
4 ? 154 260 109 253 134 125 116 115
5 255 154 238 101 239 132 117 116 107
5 255 154 238 109 253 134 125 116 115

 

 It can be noted that the irst row, in the forst table, become the first and second rows in the secind table, this arrange is new for me. i will thank you a lot because i have 500observations and make it manualy will be dificult to proceed..

 

thanks you very much

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

data have;
input ( Sample A B C D E F G H I J K L M N O P Q R) ($);
datalines;
1 255 341 154 154 238 238 ? ? 253 253 134 134 117 125 116 116 ? ?
2 255 335 154 154 238 250 101 101 239 253 134 134 117 125 116 116 107 115
3 255 319 154 154 238 238 101 109 239 253 134 134 117 125 116 116 107 115
4 ? ? 154 154 238 260 101 109 239 253 134 134 125 125 116 116 107 115
5 255 255 154 154 238 238 101 109 239 253 132 134 117 125 116 116 107 115
;
data want;
set have;
array ar(*) a--r;
output;
do _n_=1 by 2 to dim(ar);
ar(_n_)=ar(_n_+1);
end;
output;
keep a c e g i k m o q;
run;

 

View solution in original post

5 REPLIES 5
novinosrin
Tourmaline | Level 20

data have;
input ( Sample A B C D E F G H I J K L M N O P Q R) ($);
datalines;
1 255 341 154 154 238 238 ? ? 253 253 134 134 117 125 116 116 ? ?
2 255 335 154 154 238 250 101 101 239 253 134 134 117 125 116 116 107 115
3 255 319 154 154 238 238 101 109 239 253 134 134 117 125 116 116 107 115
4 ? ? 154 154 238 260 101 109 239 253 134 134 125 125 116 116 107 115
5 255 255 154 154 238 238 101 109 239 253 132 134 117 125 116 116 107 115
;
data want;
set have;
array ar(*) a--r;
output;
do _n_=1 by 2 to dim(ar);
ar(_n_)=ar(_n_+1);
end;
output;
keep a c e g i k m o q;
run;

 

Astounding
PROC Star

A good approach!  I think you want to add SAMPLE to the KEEP list.

novinosrin
Tourmaline | Level 20

@Astounding  Thank you Sir!

jonatan_velarde
Pyrite | Level 9

Awesome:

 

just correct to:

 

data want;
set have;
array ar(*) a--r;
output;
do _n_=1 by 2 to dim(ar);
ar(_n_)=ar(_n_+1);
end;
output;
keep Sample a c e g i k m o q;
run;

proc print data = want;
run;

 

Keep SAMPLE;

 

Best regards

novinosrin
Tourmaline | Level 20

Yes @jonatan_velarde  Thank you. I realised that later. Sorry I was awfully sleepy last night when i wrote it. Anyways, the same problem is actually even more easy to solve using proc iml. I will have that discussion for later as I am still tired 🙂 Have a good sunday

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 5 replies
  • 763 views
  • 2 likes
  • 3 in conversation