Hi All,
i have one issue regarding the sas code in my data have licnum it contains sum non numeric values like . $ A so i want to substitute the non numeric values to 0 plz kindly share the solution for the below issue
{
data licnum;
infile datalines;
input @1 licno 10.;
datalines;
12..994432
980..e221..
;
run;
data numchg;
set licnum;
if licno = . then licno = 0;
run;
kindly give sum solution for the above issue and mainly it's a sasmainframe
Thanks $ Regards
Rohit
Your code is not wrong. You just use one of the many possible ways of mapping a missing to 0. These are a few other options:
data licnum; infile datalines; input @1 licno 10.; /* Alternatives. Use one. */ licno = coalesce(licno, 0); licno = sum(licno, 0); if licno = . then licno = 0; ...
Hope this helps.
-- Jan.
Please do always (as in
ALWAYS!
) post the whole log of a step, and do always (as in
ALWAYS!
) use this button for posting logs:
We always ask this not because we're extremely bored, but because only whole logs help in diagnosing problems, and the </> window keeps the log as it is, without destroying the formatting.
You already have more than one solution. If COALESCE() doesn't work for you, use one of the other suggested methods:
Either:
LICNO = SUM(LICNO, 0);
Or:
if LICNO = . then LICNO=0;
You can put that in straight after the INPUT statement. No need for a second data step;
Hope this helps,
- Jan.
Please share the log in the window that appears when you click on the </> icon, as requested
You must have a very old SAS version. Use one of the other suggestions.
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.