BookmarkSubscribeRSS Feed
LinyuanQin
Calcite | Level 5

Hello everyone:

I want the data in the form below to be read into SAS as the wanted form:

original form:

>yal1 t1 awd123456789

GATA

ACC

>yal2 t2 gfs12354687987984565621321654987

TGACAG

GC

>yal3 t3 gfs1235468798798456562132165498789879875468798652135469798987987987985465798798

ATG

TGAG

wanted form:

yal1 t1 GAT

yal1 t1 AAC

yal1 t1 C

yal2 t2 TGA

yal2 t2 CAG

yal2 t2 GC

yal3 t3 ATG

yal3 t3 TGA

yal3 t3 G

data_null_ had helped me partially deal with it, and I wonder is there any statement that could push back the

POINTER if I want to use the statment "if x="<" then PUSH THE POINTER BACK" so the statement "input @'>'" could take

effect?

Thanks for any help.

4 REPLIES 4
Tom
Super User Tom
Super User

You can move the pointer back within the current input line by using + with a negative number inside of parentheses.

data test;

  input char5 $char5. +(-2) char2 $char2. ;

put char5= char2= ;

cards;

12345

run;

data_null__
Jade | Level 19

Consider this variation on the program that discarded the partial sequences.

filename FT15F001 temp;
data dna;
   infile FT15F001 n=2 eof=eof;
   input  @'>' id :$10. name :$10. / x $1. @;
   if x eq '>' then lostcard;
   length dna $3;
  
do while(x ne '>');
      dna = catt(dna,x);
     
do i = 2 to 3;
        
input x $1. @;
         if x eq '>' then do;
           
output;
           
goto nextid;           
           
end;
         dna = catt(dna,x);
        
end;
     
output;
      dna =
' ';
     
input x $1. @;
      end;
nextid:
input @1 @@;
   return;
eof:
output;
  
stop;
  
drop i x;
   parmcards;
>yal1 t1 awd123456789
GATA
ACC
>yal4 t4 gfs12354687987984565621321654987
TGACAG
GCG
>yal2 t2 gfs12354687987984565621321654987
TGACAG
GC
>yal3 t3 gfs1235468798798456562132165498789879875468798652135469798987987987985465798798
ATG
TGAG
;;;;
  
run;
LinyuanQin
Calcite | Level 5

Thanks again data_null_! I really appreciate your code to this question!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 804 views
  • 2 likes
  • 3 in conversation