Hi,
Can anyone tell me how can i delete all the Geography from rows which are having zero value while summing for that geography. There are around 10,000 different Geographies in my dataset.
I have attached the excel file for reference.
Something like this?
data have;
input Geography$ Variable_Value;
datalines;
Geo00001 1
Geo00001 3
Geo00001 4
Geo00001 5
Geo00002 0
Geo00002 0
Geo00002 0
Geo00002 0
Geo00003 5
Geo00003 0
Geo00003 0
Geo00003 7
Geo00003 0
Geo00003 2
Geo00004 0
Geo00004 0
Geo00004 0
Geo00004 0
Geo00004 0
;
proc sort data=have;
by Geography;
run;
/* Data set approach */
data want;
set have(where=(Variable_Value ne 0));
by Geography;
if first.Geography then sum=0;
else sum+Variable_Value;
retain sum;
if last.Geography;
run;
Post test data in the form of a datastep, within the body of the post, using the {i} code window.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.