Need help with doing the following... dont know where to start or how to do it! :smileyconfused:
seems pretty hard to do!
Hi,
data want;
set have;
retain artname2 artedit_id;
if substr(art_name,1,1) ne "2" then do;
artname2=art_name;
artedit_id=art_name;
end;
Run;
They there RW9,
this was very helpful, and much easier than I thought.
just 2 questions;
1. can you explain to me : if substr(art_name,1,1) ne "2" then do;
2. in artedit_id=art_name; how does one concatenate 2 different data types - a character and number, does a copy of version need to be created as a character and then concatenated with art_name_2?
thanking you & regards,
m.
hello RW9,
following on from my post below.
i got this done.
i did it over a number of data steps, but its okay i guess, it got the job done
data test;
set sample_wiki7;
retain artname2 artedit_id;
if substr(art_name,1,1) ne "2" then do;
artname2=art_name;
end;
run;
data test2;
set test;
version2 = put(version, 3.) ;
run;
data test3;
set test2;
ID = catx('', artname2,version2) ;
run;
Hi,
For your questions:
1) It basically means if the first character of art_name is a 2, so it s not one we hold over the next rows, then retain that value.
2) To concatenate different types, there is several options. The main one would be put (and input) which convert data. So string || put(number,best.) will transform the number into a string defined by the format - best. in this case) - and then concatenate that string to the other.
Glad you got your job done, you can wrap up the code lines as:
data test;
set sample_wiki7;
retain artname2 artedit_id;
if substr(art_name,1,1) ne "2" then do;
artname2=art_name;
end;
version2 = put(version, 3.) ;
ID = catx('', artname2,version2) ;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.