Dear All,
Can some one guide me with the below query.
Part 1/Cycle 1/Day 1/Pre-Dose: I have to output only: Cycle 1/Day 1 from adjacent string(Have to strip off values before the first slash and after the last).
Part 1/Cycle 1/Day 1/6 Hr: Cycle 1/Day 1
Part 1/Cycle 1/Day 15/Pre-Dose: Cycle 1/Day 15
Part 1/Cycle 1/Day 8: Cycle 1/Day 8
Part 1/Cycle 1/Day 21: Cycle 1/Day 21
Also, Can someone please guide in converting 10FEB2015 into SAS DATE.
Thanks in advance.
Rakesh
To pull out the middle pieces, here is an approach:
var = cats(scan(var, 2, '/'), '/', scan(var, 3, '/'));
I am afraid not. You have not provided any information - e.g. test data in the form of a datastep, or what you want the output to look like. This code shows how you could trim off the first and fourth part - assuming your data is all four long:
data want; a="Part 1/Cycle 1/Day 1/Pre-Dose"; b=strip(tranwrd(tranwrd(a,scan(a,4,"/"),""),scan(a,1,"/"),"")); run;
And this "10FEB2015" can be converted by using input("10FEB2015",date9.), or just "10FEB2015"d;
However further than that I can't say.
Hi,
Please find the below sample data. the data highlighted in blue is the sample data and output i would need is highlighted in PINK.
Part 1/Cycle 1/Day 1/6Hr: Cycle 1/Day 1
Part 1/Cycle 1/Day 15/Pre-Dose: Cycle 1/Day 15
Part 1/Cycle 1/Day 8: Cycle 1/Day 8
Part 1/Cycle 1/Day 21: Cycle 1/Day 21
If the data is as described, the SCAN function is sufficient.
To pull out the middle pieces, here is an approach:
var = cats(scan(var, 2, '/'), '/', scan(var, 3, '/'));
As your number of slashes is not always the same I would take the rule literally and look for first and last slash:
data test;
length string $100;
infile cards dlm='#';
input string $;
firstslash=findc(string, '/');
lastslash=findc(string, '/', '', -100);
want=substr(string, firstslash+1, lastslash-firstslash-2);
cards;
Part 1/Cycle 1/Day 1/6Hr
Part 1/Cycle 1/Day 15/Pre-Dose
Part 1/Cycle 1/Day 8
Part 1/Cycle 1/Day 21
;
Hope this helps,
- Jan
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: