1 | AF | Afghanistan | 0.213 | 0.188 | 0.0997 | 0.0891 | 0.08 | 0.0727 | 0.066 | 0.0597 | 0.0552 | 0.0423 | 0.0385 | 0.039 | 0.0487 | 0.0518 | 0.0394 | 0.0529 | 0.0637 | 0.0854 | 0.154 | 0.242 | 0.294 | 0.412 | 0.35 |
2 | AL | Albania | 1.68 | 1.31 | 0.776 | 0.732 | 0.613 | 0.672 | 0.652 | 0.499 | 0.565 | 0.958 | 0.968 | 1.03 | 1.2 | 1.38 | 1.34 | 1.38 | 1.28 | 1.3 | 1.46 | 1.48 | 1.56 | 1.79 | 1.68 |
3 | DZ | Algeria | 2.97 | 2.98 | 2.95 | 2.96 | 3.05 | 3.3 | 3.3 | 2.92 | 3.53 | 2.99 | 2.82 | 2.67 | 2.81 | 2.83 | 2.7 | 3.22 | 2.99 | 3.19 | 3.16 | 3.42 | 3.3 | 3.29 | 3.46 |
4 | AS | American Samoa | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . |
5 | AD | Andorra | 7.47 | 7.18 | 6.91 | 6.74 | 6.49 | 6.66 | 7.07 | 7.24 | 7.66 | 7.98 | 8.02 | 7.79 | 7.59 | 7.32 | 7.36 | 7.3 | 6.75 | 6.52 | 6.43 | 6.12 | 6.12 | 5.87 | 5.92 |
6 | AO | Angola | 0.42 | 0.405 | 0.401 | 0.431 | 0.281 | 0.769 | 0.712 | 0.489 | 0.471 | 0.574 | 0.58 | 0.573 | 0.721 | 0.498 | 0.996 | 0.98 | 1.1 | 1.2 | 1.18 | 1.23 | 1.24 | 1.25 | 1.33 |
If your input data set is "HAVE" then use:
data want;
set have;
array k _numeric_;
if dim(k) = n(of k[*]);
run;
Hi,
Thank you for your reply.
I have tried your code and it works. However,the output data shows there are 152 rows but the given answer saids it should be 176 rows.
Do you have another solution that I can try?
Thank you
If all Numeric variables in an observation are missing then use this:
data want;
set have;
array k _numeric_;
if nmiss(of k[*]) = dim(k) then delete;
run;
May be your specification is not understood. Let us work with an example.
data have; input x :$8. y1 y2 y3; datalines; AAAAA 10 20 30 BBBBB 10 . . CCCCC . . . ; run;
In this dataset, I understood that you want the first two rows only. So my code with suggestion made by @Astounding :
data want; set have; if nmiss(of _numeric_ ) = dim(k) then delete; run;
produces the first two records.
Can you explain your issue using this example?
The revised code was not tested. Here is the solution:
data want; set have; array k _numeric_; if nmiss(of _numeric_ ) = dim(k) then delete; run;
Also, the code shown by @Astounding can be adapted as:
data want; set have; if n(of _numeric_) NE 0; run;
Hope this solves your difficulty. All the best.
Both the programs work fine. I suspect your input dataset. Proc Print your dataset for visualization and check for any inconsistency, particularly for the DELIMITERs.
I was curious and tried your example data set. It works fine. See the output:
I tried again it still doesn't work. Can you please try to copy my code and use the data "combined" to try your code again and see if it work? data world_attr; set mapsgfk.world_attr; run; proc sort data=world_attr; by IDNAME; run; data world_attr; set world_attr; rename IDNAME=country; run; data combined; merge world_attr co2_emission; by country; run;
I looked at the data for 176 countries in the Excel sheet giving CO2 Emissions. I don't see world_attr data set. You have not told the location for that.
Further, Excel sheet, I do not see "American Samoa" as you have given in your first post.
I insist that you closely examine your input data and DO the homework before asking further questions. Show your log for all your steps. If it is voluminous use sample of 20 rows. I am not your programmer to do all.
Good luck for finding the solution.
your work.
Do you want to delete observations where all values are missing or observations where at least one value is missing?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.