Hi everyone.
My data looks something like this:
Location Count1 Count2 Count3
1 12 7
2 10 13 2
3 5
4 8 12 15
And I want the data to look like this:
Location Count
1 12
2 10
3 5
4 8
2 13
4 12
1 7
2 2
4 15
Thanks for your help.
HI @yoyong555
data have;
input Location Count1 Count2 Count3;
cards;
1 12 . 7
2 10 13 2
3 5 . .
4 8 12 15
;
proc transpose data=have out=temp(where=(col1 ne .));
by location;
run;
proc sort data =temp out=want(drop=_name_);
by _name_;
run;
Hi @yoyong555 I think you are refering to DATA HAVE step. That was just to create a sample and yes you would have to indicate with a . for missing values especially when you are trying to read raw data using LIST input . But as long as your sample is a representative one of your real, do not be concerned about that.
You just need to focus on
proc transpose data=have out=temp(where=(col1 ne .));
by location;
var count:;
run;
proc sort data =temp out=want(drop=_name_);
by _name_;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.