BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GeorgeSAS
Lapis Lazuli | Level 10

Hello everyone,

 

I want infile a raw data with comma dlm, I don't want to name for each columns so want to use a simple way:

data readraw;
infile "c:\test\abc.txt" dsd dlm=',' MISSOVER LRECL=2000  firstobs=2;
INPUT var1 $ var2 $ var3 $ var4 var5 $ /*i have total 300 columns need to be read,,,,,,,,,,;*/;

RUN;

I have 300 columns need to be read, is there an simple way to do this? like input var1 $ -- var300 ??

 I know numeric variable works in this way ,but character not....

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Yes 

 

input (var1 - var300) ($); 

 

and if you want to specify length, just do so like

input (var1 - var300) (:$8.); 

or using length statement

 

length var1-var300 $10;
input var1-var300;

 

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

Yes 

 

input (var1 - var300) ($); 

 

and if you want to specify length, just do so like

input (var1 - var300) (:$8.); 

or using length statement

 

length var1-var300 $10;
input var1-var300;

 

novinosrin
Tourmaline | Level 20

Also, you could try this

 

array var{300} $;
input var{*} ;

 and if you want to specify length, just do so like

 

array var{300} $8;
input var{*} ;
error_prone
Barite | Level 11

If you don't need all variables as character, try using proc import:

 

proc import file="c:\test\abc.txt"  dbms=csv  out=work.class replace;
	getnames=no;
run;
GeorgeSAS
Lapis Lazuli | Level 10

 (var1 - var5) ($);

 

this is good answer

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1123 views
  • 8 likes
  • 3 in conversation