BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
data march;
input id name$ score;
datalines;
1 aaa 55
2 bbb 77
3 ccc 22
4 ddd  p
5 eee  4
6 ff   k
;
run;

/* update values above datasets */

data march;
modify march;
if score=p then score=98;
run;

hi i want to update value of score where score= p then i want change 98  but above update where character value i want only required value to change

4 REPLIES 4
Astounding
PROC Star
To get your first DATA step to work, add a MISSING statement:

data march;
missing p k;
input id name$ score;
datalines;
use the same data you are using now
;

This lets you store p and k as numeric values without needing to change anything to 98. In fact, changing them to 98 would cause problems later. For example, when you calculate the average score, values of 98 would affect the average.
PaigeMiller
Diamond | Level 26

This is obviously a made up problem, but changing an invalid value, like the letter P, to a valid value, is a very poor practice. Better you should leave the P as missing, SAS does the correct things when it encounters a missing value. SAS will probably not do the correct things when it finds a 98.

--
Paige Miller

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1151 views
  • 0 likes
  • 4 in conversation