Hi
Here I am trying to data manipulate using do loop
data dsn;
do Sex= 1 to nobs ;
length sex $ 12 ;
set sashelp.class nobs=nobs;
if Sex='F' then Sex='Female';
output;
end;
proc print;
run;
I don't understand what the purpose of the DO loop is in that program. If you want to recode the value used for females just do:
data WANT;
length sex $12 ;
set sashelp.class ;
if Sex='F' then Sex='Female';
run;
@BrahmanandaRao wrote:
I Know if condition so that I just trying do loops I took small dataset suppose if huge data then
The number of observations does not impact the code.
Hi:
If all you want to do is change the display of the variable for PROC PRINT, you can use a user-defined format for that. See #1 below. If you want to create a new character variable, then you can also do that with a user-defined format and the PUT function, no DO Loop or IF statement needed. See #2 example below.
Cynthia
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.