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

Please help me with code.

I'd like to get table with 2 columns: title1 & last value in a row (in i.e. bold) = last column with value from title2 to title_n. Number of columns is not known, it can be 100 or more.

title1title2title3title4title5
B643B0CB643B0C3090E43BCC0E188F2E437
EF6E8A4EF6E8A4   
D1CA75BD1CA75B8AF3241DC24E41 
30CCDFB30CCDFB379E9CF  
E498CD8E498CD8   
58CB971BD6A93EBD6A93E  
27B35FC27B35FCC4F7E5D4F507FE8F00A10
EA06B97EA06B97BD6A93E11692E8 
ADFD3E7ADFD3E71794801  
1B43CC41B43CC4984A9CE2F9769A1540CC5

 

Hope for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

please try coalescec

 

data want;
set have;
last=coalescec(of title5-title2);
keep title1 last;
run;
Thanks,
Jag

View solution in original post

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16

please try coalescec

 

data want;
set have;
last=coalescec(of title5-title2);
keep title1 last;
run;
Thanks,
Jag
J_J_J
Obsidian | Level 7

novinosrin
Tourmaline | Level 20

Hi @J_J_J   

 


data have;
infile cards truncover;
input (title1	title2	title3	title4	title5) (:$10.);
cards;
B643B0C	B643B0C	3090E43	BCC0E18	8F2E437
EF6E8A4	EF6E8A4	 	 	 
D1CA75B	D1CA75B	8AF3241	DC24E41	 
30CCDFB	30CCDFB	379E9CF	 	 
E498CD8	E498CD8	 	 	 
58CB971	BD6A93E	BD6A93E	 	 
27B35FC	27B35FC	C4F7E5D	4F507FE	8F00A10
EA06B97	EA06B97	BD6A93E	11692E8	 
ADFD3E7	ADFD3E7	1794801	 	 
1B43CC4	1B43CC4	984A9CE	2F9769A	1540CC5
;


data want;
set have;
array t(*) title:;
want=choosec(dim(t)-cmiss(of t(*)),of t(*));
run;
J_J_J
Obsidian | Level 7

Thanks

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 484 views
  • 1 like
  • 3 in conversation