I have a problem with the F. command in xtset. The relevant part of the dataset is:
For a given panel, I get:
I want to generate a variable containing the next year's countrycode and authid. The commands
give the following outcome:
While the countrycode is correct, the afid is reduced by 1 or 2. I cannot think of an error which would determine this behaviour, and any help would be much appreciated (PS this is my first post, so apologies if I have inadvertently missed some convention).
Code:
. xtset authid year
. d authid year afid countrycode
Variable Storage Display Value
name type format label Variable label
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
authid double %15.0g Scopus identifier of author
year float %9.0g
afid long %15.0g Scopus identifier of affiliation.
countrycode int %52.0g etich country-code
Code:
. list year authid afid* countrycode* if authid == 7003989689
+-----------------------------------------------+
| year authid afid countrycode |
|-----------------------------------------------|
549793. | 1988 7003989689 60016418 United Kingdom |
549794. | 1989 7003989689 60033125 United Kingdom |
549795. | 1990 7003989689 60033125 United Kingdom |
549796. | 1991 7003989689 60033125 United Kingdom |
549797. | 1992 7003989689 60033125 United Kingdom |
|-----------------------------------------------|
549798. | 1993 7003989689 60033125 United Kingdom |
549799. | 1994 7003989689 60033125 United Kingdom |
549800. | 1995 7003989689 60015138 United Kingdom |
549801. | 1996 7003989689 60015138 United Kingdom |
549802. | 1997 7003989689 60015138 United Kingdom |
|-----------------------------------------------|
549803. | 1998 7003989689 60015138 United Kingdom |
549804. | 1999 7003989689 60027509 Italy |
+-----------------------------------------------+
Code:
. gen countrycode_next = F.countrycode (2,901,342 missing values generated) . gen afid_next = F.afid (2,901,342 missing values generated)
Code:
. list year authid afid* countrycode* if authid == 7003989689
+-------------------------------------------------------------------------------------------------------------------------------+
| year authid afid afid_n~t afid_s~o countrycode countrycode_~t |
|--------------------------------------------------------------------------------------------------------------------------|
549793. | 1988 7003989689 60016418 60033124 . United Kingdom United Kingdom |
549794. | 1989 7003989689 60033125 60033124 . United Kingdom United Kingdom |
549795. | 1990 7003989689 60033125 60033124 . United Kingdom United Kingdom |
549796. | 1991 7003989689 60033125 60033124 . United Kingdom United Kingdom |
549797. | 1992 7003989689 60033125 60033124 . United Kingdom United Kingdom |
|---------------------------------------------------------------------------------------------------------------------|
549798. | 1993 7003989689 60033125 60033124 . United Kingdom United Kingdom |
549799. | 1994 7003989689 60033125 60015136 . United Kingdom United Kingdom |
549800. | 1995 7003989689 60015138 60015136 . United Kingdom United Kingdom |
549801. | 1996 7003989689 60015138 60015136 . United Kingdom United Kingdom |
549802. | 1997 7003989689 60015138 60015136 . United Kingdom United Kingdom |
|----------------------------------------------------------------------------------------------------------------|
549803. | 1998 7003989689 60015138 60027508 . United Kingdom Italy |
549804. | 1999 7003989689 60027509 . . Italy . |
+-----------------------------------------------------------------------------------------------------+
