Reputation: 1
I have multiple conditional where statements for one variables such as:
where del="AG"; *argentina;
where del="BL"; *brazil;
etc.
I want to do the following proc freq:
proc freq data=latam;
tables hem*year/missing norow nopercent;
where del="AG"; *argentina;
run;
looped through all of these values for DEL:
"AG"="ARGENTINA"
"BL"="BRAZIL"
"BO"="BOLIVIA"
"CK"="COLOMBIA"
"CL"="CHILE"
"CR"="COSTA RICA"
"CU"="CUBA"
"DR"="DOMINICAN REPUBLIC"
"EC"="ECUADOR"
"ES"="EL SALVADOR"
"GT"="GUATEMALA"
"HO"="HONDURAS"
"MX"="MEXICO"
"NQ"="NICARAGUA"
"PE"="PERU"
"PN"="PANAMA"
"PR"="PUERTO RICO"
"PY"="PARAGUAY"
"UY"="URUGUAY"
"VE"="VENEZUELA"
How can I write this so I don't have repeat the proc for each country?
Upvotes: 0
Views: 36
Reputation: 51566
If the data is sorted by DEL then you could use a BY statement.
proc freq data=latam;
by del;
tables hem*year/missing norow nopercent;
run;
If not then you could have PROC FREQ do the organization for you by including DEL in the TABLES statement. That will cause PROC FREQ to produce a separate table for each value of DEL.
proc freq data=latam;
tables del*hem*year/missing norow nopercent;
run;
Upvotes: 0
Reputation: 27498
Welcome to SAS. Use a BY
statement.
proc sort data=latam;
by del;
run;
proc freq data=latam;
by del;
tables hem*year/missing norow nopercent;
run;
Upvotes: 1