Unique ID for every section

Discussions about editing and cleaning data
Forum rules
New release: CSPro 8.0
Post Reply
selaba
Posts: 2
Joined: May 20th, 2016, 11:38 am

Unique ID for every section

Post by selaba »

Hi all,

I'm new to CSPro and despite being a newbie, our group decided to use it in our household survey. The survey questionnaire consisted of 8 sections. When we programmed the data entry, the only id we assigned to is the household id (which corresponds to each questionnaire). We forgot to take into consideration the individual id that would later on be used in the analysis. As such, when I concatenated the data, there is no unique id per individual per section. Is there a remedy to this? Is it possible to insert a program such that each member in the household would have a corresponding id per section? Thanks!

Sel
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Unique ID for every section

Post by josh »

I'm assuming that the individuals in each household are in record occurrences - i.e. you have one or more records in your dictionary that are repeated for each individual. If that is the case then you can add a new item to the record for the individual and fill it in using a batch edit program using the currocc() function. The currocc() function returns the occurrence number, aka line number, of the record. One for the first individual record in the questionnaire, two for the second individual... This will therefore be unique for each individual record.

In your data dictionary make sure to add the new variable to the end of the record, otherwise you will shift the positions of the items that have existing data and they will no be longer readable using that dictionary. If your new variable is named INDIVIDUAL_NUMBER then in the batch edit program you can simply add:

PROC INDIVIDUAL_NUMBER
INDIVIDUAL_NUMBER = currocc();
Saint
Posts: 63
Joined: November 22nd, 2013, 4:59 am

Re: Unique ID for every section

Post by Saint »

Another option is to export the data as 'wide' and then reshape to 'long'
selaba
Posts: 2
Joined: May 20th, 2016, 11:38 am

Re: Unique ID for every section

Post by selaba »

Dear Josh,

Thanks for your reply. I followed your suggestion however I only got missing observations when I exported the data to Stata. :(
Attachments
Stata.jpg
Stata.jpg (291.45 KiB) Viewed 9138 times
Add item.jpg
Add item.jpg (225.62 KiB) Viewed 9138 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Unique ID for every section

Post by josh »

Since you are running this on existing data you should put the logic to add the individual number in a batch edit application. Run the batch edit application using the original data file as the input file and specify the name of a new file to use as the output file. Batch edit never modifies the input file so it will still be missing the individual numbers. When you export to Stata make sure to use the output file from batch edit as this will have the individual numbers.
MrTaco
Posts: 128
Joined: November 18th, 2014, 1:55 am

Re: Unique ID for every section

Post by MrTaco »

Hi

Export it to SPSS and convert it to STATA, that way you will be able to get complete roster information
Post Reply