I Have Dataset Like below..
data ds;
infile datalines;
length number $10.;
input number$;
datalines;
1
1 1
1 1 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
;
run;
Through this dataset i want output like below..
0000000001
0000000011
0000000111
0000001111
0000011111
0000111111
0001111111
0011111111
0111111111
1111111111
Please anyone help to solve this question..write a programme for this...
Great that you've posted sample data in the form of a SAS datastep. Even better would be if you also test the datastep to ensure it fully works and we don't have to fix it.
I believe below returns what you've been asking for.
data ds;
infile datalines;
length number $20.;
input number $20.;
length number2 8;
format number2 z10.;
number2=input(compress(number),best32.);
datalines;
1
1 1
1 1 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
;
proc print data=ds;
run;
data ds;
infile datalines;
input number $40.;
length temp $ 10;
temp=compress(number,' ');
want=translate(right(temp),'0',' ');
datalines;
1
1 1
1 1 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
;
proc print;run;
If You dont mind please write a full programme for that !!!!
Sorry Its not look like as want my output..Zeros are come between the 1's..but in our output zero's come infront of 1 only..
please have a look on your programme and do some changes..and send it fastly to me..
Opps. code has been modified.
Great that you've posted sample data in the form of a SAS datastep. Even better would be if you also test the datastep to ensure it fully works and we don't have to fix it.
I believe below returns what you've been asking for.
data ds;
infile datalines;
length number $20.;
input number $20.;
length number2 8;
format number2 z10.;
number2=input(compress(number),best32.);
datalines;
1
1 1
1 1 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
;
proc print data=ds;
run;
Any Another programme for this question ?? If you have another type programme please send it to me now...!!!!
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.