Hello,

I'm currently working with NHANES data attempting to combine multiple survey years together to identify the most common prescriptions used over time and in specific cycles among a specific subpopulation. I am attempting to obtain weighted and unweighted results for the most common medications.

The data, after combining together, is long. I converted it to wide; however, I have potentially drug1-drug 21 which I'm not quite sure how to identify most common from that. Instead, I'd think most prefer to work with the data in long form and collapse across cycles and by person. Any assistance would be appreciated either if the data is reported as long (shown below) or across with one row for each person in the cycle as drug1-drug21, for example.

Code:
*unweighted--overall and by subpop;
tab rxddrug if cycle==1 & inAnalysis==1 & subpop!=., sort 
tab rxddrug if cycle==1 & subpop==1 & inAnalysis==1, sort
tab rxddrug if cycle==1 & subpop==0 & inAnalysis==1, sort
I use 2 cycles here as an example:

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input double seqn float cycle str114 rxddrug float(inAnalysis subpop)
51624 1 "CIMETIDINE"                      0 0
51624 1 "DULOXETINE"                      0 0
51624 1 "LEVETIRACETAM"                   0 0
51625 1 ""                                0 0
51626 1 ""                                0 0
51627 1 ""                                0 0
51628 1 "CARVEDILOL"                      0 0
51628 1 "ENALAPRIL; HYDROCHLOROTHIAZIDE"  0 0
51628 1 "ESOMEPRAZOLE"                    0 0
51628 1 "GLIMEPIRIDE"                     0 0
51628 1 "LEVOTHYROXINE"                   0 0
51628 1 "TRAMADOL"                        0 0
51629 1 ""                                0 0
51630 1 "ACYCLOVIR"                       0 0
51630 1 "BUPROPION"                       0 0
51630 1 "DOCUSATE"                        0 0
51630 1 "HYDROCHLOROTHIAZIDE; OLMESARTAN" 0 0
51630 1 "IBUPROFEN"                       0 0
51631 1 "DONT KNOW"                       0 0
51632 1 "METHYLPHENIDATE"                 0 0
51633 1 "TAMSULOSIN"                      0 0
51634 1 ""                                0 0
51635 1 "AMLODIPINE"                      0 0
51635 1 "METOPROLOL"                      0 0
51635 1 "OMEPRAZOLE"                      0 0
51635 1 "SIMVASTATIN"                     0 0
51635 1 "TAMSULOSIN"                      0 0
51636 1 ""                                0 0
51637 1 ""                                1 0
51638 1 ""                                0 0
51639 1 ""                                0 0
51640 1 "DEXMETHYLPHENIDATE"              0 0
51640 1 "FLUTICASONE; SALMETEROL"         0 0
51640 1 "LEVALBUTEROL"                    0 0
51640 1 "MONTELUKAST"                     0 0
51641 1 ""                                0 0
51642 1 ""                                0 0
51643 1 "BUPROPION"                       1 0
51643 1 "CALCIUM ACETATE"                 1 0
51643 1 "DICYCLOMINE"                     1 0
51643 1 "EFAVIRENZ"                       1 0
51643 1 "EMTRICITABINE"                   1 0
51643 1 "INSULIN GLARGINE"                1 0
51643 1 "LOSARTAN"                        1 0
51643 1 "METOCLOPRAMIDE"                  1 0
51643 1 "OMEPRAZOLE"                      1 0
51643 1 "OXCARBAZEPINE"                   1 0
51643 1 "PERPHENAZINE"                    1 0
51643 1 "PRAVASTATIN"                     1 0
51643 1 "PROPRANOLOL"                     1 0
51643 1 "RALTEGRAVIR"                     1 0
51643 1 "VALACYCLOVIR"                    1 0
51644 1 "AZITHROMYCIN"                    0 0
51645 1 "LOVASTATIN"                      0 0
51645 1 "METOPROLOL"                      0 0
51646 1 "BUDESONIDE"                      0 0
51647 1 "BUPROPION"                       0 0
51647 1 "FLUOXETINE"                      0 0
51648 1 ""                                0 0
51649 1 ""                                0 0
51650 1 ""                                0 0
51651 1 ""                                0 0
51652 1 ""                                0 0
51653 1 ""                                0 0
51654 1 "HYDROCHLOROTHIAZIDE; LISINOPRIL" 0 0
51655 1 ""                                0 0
51656 1 "EZETIMIBE; SIMVASTATIN"          0 0
51657 1 ""                                0 0
51658 1 "ACETAMINOPHEN; HYDROCODONE"      1 0
51659 1 ""                                0 0
51660 1 ""                                0 0
51661 2 "ALPRAZOLAM"                      0 0
51661 2 "BROMAZEPAM"                      0 0
51661 2 "CLINDAMYCIN"                     0 0
51661 2 "DICYCLOMINE"                     0 0
51661 2 "IBUPROFEN"                       0 0
51661 2 "METOCLOPRAMIDE"                  0 0
51661 2 "RABEPRAZOLE"                     0 0
51661 2 "TRAMADOL"                        0 0
51662 2 ""                                1 0
51663 2 ""                                0 0
51664 2 "EZETIMIBE; SIMVASTATIN"          0 0
51665 2 ""                                0 0
51666 2 ""                                0 0
51667 2 "AMLODIPINE"                      0 0
51667 2 "CHLORTHALIDONE"                  0 0
51667 2 "SIMVASTATIN"                     0 0
51668 2 "ALBUTEROL"                       0 0
51668 2 "INSULIN ZINC"                    0 0
51669 2 ""                                0 0
51670 2 ""                                0 0
51671 2 ""                                0 0
51672 2 ""                                1 0
51673 2 "ETHINYL ESTRADIOL; NORGESTIMATE" 1 0
51674 2 ""                                1 0
51675 2 "ALENDRONATE"                     0 0
51675 2 "ATORVASTATIN"                    0 0
51675 2 "LEVOTHYROXINE"                   0 0
51675 2 "LISINOPRIL"                      0 0
51675 2 "METOPROLOL"                      0 0
end
label values cycle _cycle
label def _cycle 1 "2009-10" 2 "2011-12", modify