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


Hi All,

I have an excel file with the following information for 9000 observations:

Company               ID                                                                                                

A            /wrds_netapp/sec2/000094/948368/0000914317-11-000380.txt

B            /wrds_netapp/sec2/000078/785024/0000916480-10-000041.txt

I want to change the link to the following

Company     ID                                                                                        New Link

A            /wrds_netapp/sec2/000094/948368/0000914317-11-000380.txt     http://www.sec.gov/Archives/edgar/data/948368/0000914317-11-000380.txt

B            /wrds_netapp/sec2/000078/785024/0000916480-10-000041.txt     http://www.sec.gov/Archives/edgar/data/785024/0000916480-10-000041.txt

In other words, I want to add http://www.sec.gov/Archives/edgar/data/ to the last 2 sections of the ID to get the actual link.

Is there a SAS code to that?

Thank you for your time.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
input Company   $            ID     : $200. ;                  
link=cats('http://www.sec.gov/Archives/edgar/data/',scan(id,-2,'/'),'/',scan(id,-1,'/')); 
cards;
A            /wrds_netapp/sec2/000094/948368/0000914317-11-000380.txt
B            /wrds_netapp/sec2/000078/785024/0000916480-10-000041.txt
;
run;

Ksharp

View solution in original post

4 REPLIES 4
Ksharp
Super User
data have;
input Company   $            ID     : $200. ;                  
link=cats('http://www.sec.gov/Archives/edgar/data/',scan(id,-2,'/'),'/',scan(id,-1,'/')); 
cards;
A            /wrds_netapp/sec2/000094/948368/0000914317-11-000380.txt
B            /wrds_netapp/sec2/000078/785024/0000916480-10-000041.txt
;
run;

Ksharp

shalmali
Calcite | Level 5


Thanks Ksharp for the code.

shalmali
Calcite | Level 5

Hi Ksharp,

Your current code works perfectly fine. But if I want the link to create an additional link (link2) by replacing ".txt" on the link with "-index.htm", what code would I need? That is, I want link2 to be http://www.sec.gov/Archives/edgar/data/785024/0000916480-10-000041-index.htm

Thank you,

Shalmali

Ksharp
Super User

OK.

data have;
input Company   $            ID     : $200. ;                  
link=cats('http://www.sec.gov/Archives/edgar/data/',scan(id,-2,'/'),'/',scan(id,-1,'/')); 
link2=tranwrd(link,'.txt','-index.htm');
cards;
A            /wrds_netapp/sec2/000094/948368/0000914317-11-000380.txt
B            /wrds_netapp/sec2/000078/785024/0000916480-10-000041.txt
;
run;

Ksharp

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 1231 views
  • 0 likes
  • 2 in conversation