Hi, The variable REFMATS has this information
However, the code i have keeps outputting the first [ as a clause and would like to update the clause code to not take the first "["
REFMATS
[Type:ADRG, URL :, Version : , Status : , Date : Notes :,[Type:P21 Report, URL :, Version : , Status : , Date : Notes :,[Type:eSub Source Data Location, URL :, Version : , Status : , Date : Notes :,[Type:eSub Data Package Location, URL :, Version : , Status : , Date : Notes :
data work._ref_mat_info (label = "Reference Materials") ;
length clause $150 ;
set test.deliverables(obs=1) ;
where REFMATS ne "";
_i = 0 ;
do until(REFMATS = "") ;
_i + 1 ;
if _i >= 100 then stop ;
_pos = index(REFMATS,'[') ;
if _pos = 0 then do ;
clause = REFMATS ;
REFMATS = "" ;
end ;
else do ;
clause = substr(REFMATS,1,_pos) ;
REFMATS = substr(REFMATS,sum(_pos,1)) ;
end ;
output ;
end ;
*keep _ref_mat clause num text ;
run ;
The clause variable keeps outputting this and I would like the first "[" to not be taken.
CLAUSE:
obs CLAUSE
1 [
2 Type:ADRG, URL :, Version : , Status : , Date : Notes :,[
3 Type:eSub Source Data Location, URL :, Version : , Status : , Date : Notes :,[
4 Type:eSub Source Data Location, URL :, Version : , Status : , Date : Notes :,[
5 Type:eSub Data Package Location, URL :, Version : , Status : , Date : Notes :
Any help is appreciated
What are you attempting to achieve, i.e. what do you want as the output for a given input.
I'm assuming you don't want the first observation in your output ("[") and probably none of the "["
Here's a potential solution using the scan function
data want ;
string="[Type:ADRG, URL :, Version : , Status : , Date : Notes :,[Type:P21 Report, URL :, Version : , Status : , Date : Notes :,[Type:eSub Source Data Location, URL :, Version : , Status : , Date : Notes :,[Type:eSub Data Package Location, URL :, Version : , Status : , Date : Notes :" ;
n=1 ;
word=scan(string,n,"[") ;
do while (word ne "") ;
output ;
n=n+1 ;
word=scan(string,n,"[") ;
end ;
run ;
What are you attempting to achieve, i.e. what do you want as the output for a given input.
I'm assuming you don't want the first observation in your output ("[") and probably none of the "["
Here's a potential solution using the scan function
data want ;
string="[Type:ADRG, URL :, Version : , Status : , Date : Notes :,[Type:P21 Report, URL :, Version : , Status : , Date : Notes :,[Type:eSub Source Data Location, URL :, Version : , Status : , Date : Notes :,[Type:eSub Data Package Location, URL :, Version : , Status : , Date : Notes :" ;
n=1 ;
word=scan(string,n,"[") ;
do while (word ne "") ;
output ;
n=n+1 ;
word=scan(string,n,"[") ;
end ;
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.