The practice of citing data sources can range from the straightforward, easily accomplished using guidance offered by style manuals such as APA's, to quite detailed, when the source data is generated on the fly based on user-selected criteria. In cases such as these, utilizing Project TIER's data citation method, which includes documenting details of the data-generation process, is necessary.
Also see the Tri-College Libraries Citation Guide.
Approaches to data documentation vary, but a good rule of thumb is is to err on providing more documentation rather than less. In the quantitative social sciences, Project TIER's Protocol provides didactic guidance suitable for undergraduate and graduate students. The American Economic Association's (AEA) Data and Code Policies and Guidance provides instruction for authors of empirical papers in AEA journals, but can be considered a useful set of guidelines for scholars conducting empirical research in any field.