BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
data test;
infile cards;
input A1 A2 A3 A4 A5;
cards;
-2 2 5 1 0
1 -2 5 1 2
;
run;
how to get only positive values ?
6 REPLIES 6
BrahmanandaRao
Lapis Lazuli | Level 10

Hi Peter,

I want get only positive values only A1 to A5 variables

ballardw
Super User

What does the actual resulting data set look like?

One interpretation of your request would remove entire observations from the data set if any of the variables are negative.

Another would be to set the negative values to missing.

Another could be create custom format so that negative values appear as blanks in printed output.

Another could be remove a variable from a data set if any of its values are negative.

 

If I were more awake I might even come up with more meanings for "only positive values"

Astounding
PROC Star
Getting only positive values is easy. For example, you could program:

data want;
set test;
A1 = 7;
A2 = 7;
A3 = 7;
A4 = 7;
A5 = 7;
run;

However, if this is not the set of positive values that you have in mind, maybe you can describe what the result should look like.
mkeintz
PROC Star

What do you mean by get in "get only positive values"?

 

I don't get it.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 644 views
  • 2 likes
  • 6 in conversation