Please format your post. Also use a proper subwindow ("little running man" or {i} icon) to post code.
It's the 6th and 7th icons above the main posting window. Both preserve all formatting, the 7th (the "little running man") also provides enhanced-editor-like coloring.
@caibird wrote:
sorry, I see no icon at all on post window. There is only 3 tab: rich text, html, preview. And it takes 3min to open/refresh the web. But I visit other website normal. 😞
See here:
The active icon in this screenshot is the "little running man" icon, the next one to the left of it is the {i} icon.
@caibird wrote:
sorry, don't know how to format. I see no button or something like that in my window. let me brief: In a data set have 4 columns A B C X. Column X="A=B=C" in all rows, I want to use "A=B=C" in below statement in same data step. if (A=B=C) then ... how to convert "A=B=C" to A=B=C? (one way is call symput('_X',X), but &_X cannot use in same data step)
Below where you see Rich Text HTML Preview, inside the window you should see a row of images starting with B. They are icons but are not buttons.
'Format' in this instance means to make your code legible to people by using (generally) one line per statement or instruction, indenting code between any sort of start /end block (data/run, proc/run, do/end, Select/end) so that program flow can be seen and understood easier.
Mostly, the complications are from trying to get macro language to perform the functions of a DATA step. Once you start a DATA step, following LENGTH CONN $ 100;, there should be no more macro language. The DATA step can handle the calculations better than macro language could. You might want a statement along these lines:
array mylist {*} &vars;
But that would be the most macro language that the DATA step requires.
If you sketch out what the program should do, with no macro language involved, you will find ways to make a DATA step do what you ask. For example, here are some possibilities:
if min(mylist{*}) = max(mylist{*}) then output;
Or possibly:
do i=1 to dim(mylist);
if mylist{i} > ' ' then conn = catx(' ', conn, vname(mylist{i}));
end;
It starts with knowing the goal ... what is the DATA step that would work, if no macro language were involved.
The data step is compiled before execution. You cannot change the code while it executes.
You can only execute already-written code conditionally with if-then-else or select()-when()-end.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.