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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 499 views
  • 0 likes
  • 2 in conversation