BookmarkSubscribeRSS Feed
My_SAS
Calcite | Level 5

I wnat to move all the data in to FInal_DATA variable if the data is . or blank in id variable with separated by |


data l2;
infile cards missover truncover;
input id id2$ id3$ id4$ id5;
cards;
. a b c .
.       .
1 q w e 2
run;

output
id id2 id3 id4 id5 FInal_DATA
. a b c .
.       .       .||||.
1 q w e 2

3 REPLIES 3
shivas
Pyrite | Level 9

Hi,

Try this..Hope it helps.

data l2;

infile cards missover truncover;

input id id2$ id3$ id4$ id5;

cards;

. a b c .

.       .

1 q w e 2

run;

data want(drop=sp);

set l2;

SP='|';

if id=. then

final_data=trim(left(id2)) || sp || trim(left(id3)) || sp || trim(left(id4))  ;

run;

Thanks,

Shiva

My_SAS
Calcite | Level 5

can u do by macro i thryed this but not getting.

proc sql;
select name into:nam separated by '|'  FROM DICTIONARY.COLUMNS where libname="WORK"
and memname="L2";
quit;

%global nam;
%put  &nam;

data l2;
set l2;
length final_data $100.;
/*CALL SYMPUT('nam',nam);*/
if id ne . then final_data=&nam.;
run;

Haikuo
Onyx | Level 15

Hi,

Your post is confusing.

1. your 'id' variable in your sample dataset is numeric, so if it is missing, it can only be '.' instead of '.' or 'blank'. Unless what you mean is all of your variables staring with 'id' are missing, which can be hinted by your output dataset. However, in your second post, you have stated 'id ne .'.

2. What is your purpose? do you want to catenate variable contents or variable names? and on what condition to do so, id eq . or id ne .? all I received is conflicted info from your first and second posts.

Haikuo

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 969 views
  • 0 likes
  • 3 in conversation