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

Hi everybody

I have a little probleme with SAS in connection with WRDS. I need to download for a large number of firms some stock data. For all the firms I have the cusip. So far I downloaded the data using this code and it worked.

libname mylib "C:\Data";

rsubmit;

%let clist = '000361' '000957' '001031' '001055' '001204' '00163U';

data stockprice;

set crsp.dsf;

where cusip in (&clist);

keep prc cusip ret;

run;

.

.

.

. and so on

But now I have to do the same download for thousands of firms. Is there a possibility to save a txt or sas7bdat file which contains the cusip's and to tell SAS that it should use this file in order to download the data from the WRDS server? In this way I do not have to copy the cusips in the download code and it would be much more easy to make the download.

Many thanks for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

/* find a way to put all the IDs in a dataset */

data have;

input cid $@@;

cards;

000361  000957   001031 001055 001204 00163U

;

/* create macro variable clist */

proc sql noprint;

select quote(cid) into :clist separated by ',' from have ;

quit;

/******************************/

libname mylib "C:\Data";

rsubmit;

data stockprice;

set crsp.dsf;

where cusip in (&clist);

keep prc cusip ret;

run;

.

.

.

. and so on

View solution in original post

2 REPLIES 2
Linlin
Lapis Lazuli | Level 10

/* find a way to put all the IDs in a dataset */

data have;

input cid $@@;

cards;

000361  000957   001031 001055 001204 00163U

;

/* create macro variable clist */

proc sql noprint;

select quote(cid) into :clist separated by ',' from have ;

quit;

/******************************/

libname mylib "C:\Data";

rsubmit;

data stockprice;

set crsp.dsf;

where cusip in (&clist);

keep prc cusip ret;

run;

.

.

.

. and so on

Ksharp
Super User

Using call execute() .

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
  • 2 replies
  • 687 views
  • 3 likes
  • 3 in conversation