// Test with Combination files SDC & Datastream // Created by Mark Bruyneel, 22-3-2016 clear * // Clear all data from Stata memory cd "u:\Werk\Datacentrum\Stata\testfiles\" // Indicate the location of the files set maxvar 3000 // Set variable max (not always necessary in every edition of Stata) import excel using DS-Prepared.xlsx, firstrow //Imports the Datastream delimited text file into Stata reshape long Y, i(CompanyCode) j(year) // Transpose data from columns to rows rename Y TotAssets // Rename variable to Total Assets tostring year, replace // Change year from numeric to string values gen UID = CompanyCode+year // Create a unique ID to merge data later drop CompanyCode // Removes unnecessary data drop year // Removes unnecessary data destring TotAssets, replace force // Turns the data from text into numbers drop if mi(TotAssets) // Removes records with no values for TotalAssets order UID // Puts the UID variable first // save Datastream, replace // Saves the dataset as a Stata dataset browse // Look at the data /* End of file */