Help using Base SAS procedures

Proc format for negative numbers

Accepted Solution Solved
Reply
Contributor
Posts: 45
Accepted Solution

Proc format for negative numbers

Dataset:

 

subj   score

1          -5.3

2          -3.4

3           1.6

4           0.4

5          -6.4

6           0

 

How would I make a new variable (score 2) where all negative values are now missing (.)?

 


Accepted Solutions
Solution
‎08-09-2016 04:59 PM
Super User
Posts: 17,784

Re: Proc format for negative numbers

If you want to recode it, use an IF condition instead.

 

IF score<0 then score=.;

 

 

 

View solution in original post


All Replies
Regular Contributor
Posts: 159

Re: Proc format for negative numbers

How's this?

 

data testSet;
   input subj score;
   datalines;
1 -5.3
2 -3.4
3 1.6
4 0.4
5 -6.4
6 0
;

proc format;
    value formatName low-<0 = .
          other = [7.2];
run;

proc sql;
    select subj
          ,score format formatName.
    from testSet;
quit;
Contributor
Posts: 45

Re: Proc format for negative numbers

how would i make the data into a new variable in my data set?

Solution
‎08-09-2016 04:59 PM
Super User
Posts: 17,784

Re: Proc format for negative numbers

If you want to recode it, use an IF condition instead.

 

IF score<0 then score=.;

 

 

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 343 views
  • 2 likes
  • 3 in conversation