Hi SAS Users,
When collecting data from Compustat, one GVKEY (company) can have multiple IID (issue identifier) , so this SAS document suggests that these two identifiers must be accessed as a pair to properly identify a Compustat security.
In SAS, this SAS document says that SAS provides GVIIDKEY=option to provide access to Compustat securities through the composite key designated by "GVKEY.IID".
However, in my case, I have the data already with GVKEY and IID in separate columns. Can I ask what I should do to generate a GVKEY.IID in my current dataset based on the above idea?
I also attach my data in the attached file, here is a quick description
GVKEY IID DATADATE PRCHD
001166 01W 04JAN1999 4.6000
001166 01W 05JAN1999 4.6000
001166 01W 06JAN1999 5.0000
001166 01W 07JAN1999 4.9000
001166 01W 08JAN1999 5.6000
001166 01W 11JAN1999 5.5000
001166 01W 12JAN1999 5.6000
While GVKEY and IID are character variables, the other two variables are numeric variables
One idea popping up in my mind is just to create a new variable named, but I am not confident if I understand the idea of GVIIDKEY correctly.
gvkey_iid=catx(_,GVKEY,IID)
Apart from that, when I run this code
libname import 'E:\Harv 27th_Feb_2021\global_daily_1999_2001' access=readonly;
/*Creating gvkeyiid var*/
data sample;
set import.qgorvcptbfwuowrm5;
gvkeyiid=catx(_,gvkey,iid);
run;
The log announced a note as below:
30 /*Creating gvkeyiid var*/
31 data sample;
32 set import.qgorvcptbfwuowrm5;
33 gvkeyiid=catx(_,gvkey,iid);
34 run;
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
33:17
NOTE: Variable _ is uninitialized.
Could you please tell me how to solve it as well?
Warmest regards!
data sample;
set import.qgorvcptbfwuowrm5;
id1=catx('_',gvkey,iid); /*add quotation mark, combine variables with _*/
id2=cats(gvkey,iid);
run;
data sample;
set import.qgorvcptbfwuowrm5;
id1=catx('_',gvkey,iid); /*add quotation mark, combine variables with _*/
id2=cats(gvkey,iid);
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.