Help using Base SAS procedures

assign a format depending of a variable

Reply
N/A
Posts: 0

assign a format depending of a variable

Hello dears SAS users
my problem is the following
take the dataset sashelp.class;
i just want (i take this example to make you understand my problem)
to assign the following formats
if it's a girl ---> new_name=put (name, $Fname.);
if it's a boy --->new_name= put(name,$Mname.);
i want to retrieve the value of sex for each line in a macro variable (of course depending of the line) and then to put something like this
new_name=put(name,$&&sex&i.name.)
in fact i have in my work to assign a format depending of the country to a numeric value
there is more than 180 differents country so i cannot use the if then else facility
and a good SAS developper says me that the only way to do it is by macro variable facility but in my code, i always put the format of the country of the last line and so, the results are bad
more generally, how can i do to do this ?
may be one idea it to cut my datastep by line but it could be so long, especially when i will have 6 000 000 of lines in my entry dataset...
Should you help me
Thank you very much
Respected Advisor
Posts: 3,777

Re: assign a format depending of a variable

Look at putC function, with this function format is an character expression.
Ask a Question
Discussion stats
  • 1 reply
  • 83 views
  • 0 likes
  • 2 in conversation