BookmarkSubscribeRSS Feed
Sandhya
Fluorite | Level 6
Hi,

I have a variable from a data set which I receive everyday from different programmers. Some would id number. Some would have it as character and some numeric. My program should check the format of the output and name it PID.

For this I tried this code but the renaming happens anyway.

data data;
set &data;
if (vformatn(&idvar) eq '$') then do;
pid=input(&idvar, 8.);
end;
else do;
rename &idvar=pid;
end;
run;

So the result is the character to numeric conversion never stays.

Please suggest something.

Thank you,
Sandhya.
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Check your DATA statement, also your SAS log should identify the problem.

Scott Barry
SBBWorks, Inc.
Sandhya
Fluorite | Level 6
I fixed it.

Instead of renaming it I assigned it to pid.

instead of rename &idvar=pid;

I used pid=&idvar;

Sandhya.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Do consider that the RENAME statement is not a type that has conditional execution. Your SAS variable rename process will occur regardless of the DO/END code piece.

It appears you may be using SAS macro language, so you may explore converting the DATA step DO/END to a macro %DO/%END, if appropriate.

Scott Barry
SBBWorks, Inc.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 694 views
  • 0 likes
  • 2 in conversation