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

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
  • 6 replies
  • 749 views
  • 1 like
  • 5 in conversation