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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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