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

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!

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
1 ACCEPTED SOLUTION

Accepted Solutions
blueskyxyz
Lapis Lazuli | Level 10
data sample;
 set import.qgorvcptbfwuowrm5;
 	id1=catx('_',gvkey,iid);  /*add quotation mark, combine variables with _*/
	id2=cats(gvkey,iid);
run;

View solution in original post

2 REPLIES 2
blueskyxyz
Lapis Lazuli | Level 10
30 /*Creating gvkeyiid var*/
31 data sample;
32 set import.qgorvcptbfwuowrm5;
33 id1=catx('_',gvkey,iid);
id2=cats(gvkey,iid);
34 run;
blueskyxyz
Lapis Lazuli | Level 10
data sample;
 set import.qgorvcptbfwuowrm5;
 	id1=catx('_',gvkey,iid);  /*add quotation mark, combine variables with _*/
	id2=cats(gvkey,iid);
run;

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