BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Mohan_Reddy
Obsidian | Level 7

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...

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

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;

View solution in original post

6 REPLIES 6
Ksharp
Super User
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;

 

Mohan_Reddy
Obsidian | Level 7

If You dont mind please write a full programme for that !!!!

Mohan_Reddy
Obsidian | Level 7

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..

Patrick
Opal | Level 21

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;
Mohan_Reddy
Obsidian | Level 7

Any Another programme for this question ?? If you have another type programme please send it to me now...!!!!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1143 views
  • 2 likes
  • 3 in conversation