I have attempted various methods, but I have been unable to obtain the desired output.
Using do loops
I need output like following;
1
121
12321
1234321
123454321
Is the output one variable? Is it numeric or character? Maximum of 5 or how many rows? (Will severely limit whether the value is numeric or not
This makes a character value with that appearance.
data example; length var $ 25; do levels = 1 to 5; call missing(var); do j=1 to levels; var=cats(var,j); end; do j=(levels-1) to 1 by (-1); var=cats(var,j); end; output; end; drop levels j; run;
Please show us what you tried, so we can suggest ways to improve/correct your code.
Is the output one variable? Is it numeric or character? Maximum of 5 or how many rows? (Will severely limit whether the value is numeric or not
This makes a character value with that appearance.
data example; length var $ 25; do levels = 1 to 5; call missing(var); do j=1 to levels; var=cats(var,j); end; do j=(levels-1) to 1 by (-1); var=cats(var,j); end; output; end; drop levels j; run;
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.