BookmarkSubscribeRSS Feed
rvsidhu035
Quartz | Level 8
data functions;
infile datalines dlm=' ' dsd missover;
input x $ 50.;
x1=scan(x,1," ");
x2=scan(x,2," ");
x3=scan(x,3," ");
x4=scan(x,4," ");
x5=scan(x,5," ");
x6=scan(x,2," ");
datalines;
abc123@#$	abc	123	@#$	 abc123	abc@#$ 
def123		def 123  	 def123 	   
456@#$   		456 @#$				   
@&*rtg 		rtg  	@&*  		@&*rtg 
qwerty	 qwerty   					   
!@#$%   			!@#$%			   
123456   		12345				   
;
run;
6 REPLIES 6
rvsidhu035
Quartz | Level 8

we want missing values if not have scan values means consecutive space take as missing values

Reeza
Super User

@rvsidhu035 wrote:

we want missing values if not have scan values means consecutive space take as missing values


You need to post more details about what your question is and what issues you're having if you need help. 

rvsidhu035
Quartz | Level 8

def123        def    123               def123

 

this one 2nd obs

here x1=def123 x2=def x3=123 x4=x5=missing,x6=def123

we want above output by using sas functions only its possible

novinosrin
Tourmaline | Level 20

I have no clue what you are after. I am guessing perhaps to fetch these records?

 

 

data functions;

infile datalines dlm=' ' dsd missover;

input x $ 50.;

datalines;

abc123@#$   abc   123   @#$   abc123     abc@#$

def123            def 123      def123        

456@#$            456 @#$                         

@&*rtg            rtg  @&*         @&*rtg

qwerty      qwerty                                

!@#$%                   !@#$%               

123456            12345                     

;

run;

 

data want;

set functions;

if anypunct(x)=0;

run;

PGStats
Opal | Level 21

Your input text is tab delimited. It reads fine from a regular text file:

 

data functions;
infile "&sasforum\datasets\rvsidhu035.txt" dsd dlm="09"x missover;
input (x1-x6) (:$10.);
run;

proc print; var x1-x6; run;
        Obs    x1           x2        x3         x4          x5        x6

         1     abc123@#$    abc       123        @#$       abc123    abc@#$
         2     def123                 def 123    def123
         3     456@#$                 456 @#$
         4     @&*rtg                 rtg        @&*                 @&*rtg
         5     qwerty       qwerty
         6     !@#$%                             !@#$%
         7     123456                 12345
PG

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 1677 views
  • 1 like
  • 5 in conversation