sas - Data Preparation with given columns in WPS -
I have a dataset that has two columns for gender and birth_date, I need output as two lines How do I do male and female (gender) and column in one year's month as a SAS?
Suppose:
gender birthdays male 01/10/1989 female 02/12/1990
and so on .. I have about 100 rows.
So I think you want the number of people born in each month.
The first data set creates some test data.
data testing; Format gender $ 8 Date of birth date 9.; Do I = 1 to 5000; Gender = "male"; Birthday = today () + roof (Bhairuni (123) * 365); Output; End; Do I = 1 to 5000; Gender = "FEMALE"; Birthdays = today () + roof (Bhairuni (123) * 365); Output; End; Drop Drop; Run; Proc sort data = test; By gender; Run; Data output (keep = gender months :); Set test; By gender; Array month_ [12]; If first.gender then; Do I = 1 to 12; Month_ [i] = 0; End; End; Month_ [month (birthday)] + 1; If the output of the previous ginger; Run;
creates
Comments
Post a Comment