LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2000, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 16 Jun 2000 11:06:47 -0400
Reply-To:     Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject:      Re: read in hundreds of new  character variables efficiently
Comments: To: paula <icj808@USWEST.NET>
Content-Type: text/plain; charset="iso-8859-1"

Subject: read in hundreds of new character variables efficiently Summary: Hire a SAS programmer Respondent: Ian Whitlock <whitloio1@westat.com>

Paula [icj808@USWEST.NET] has recently been asking about questions about SAS training and interview questions and the hiring of people with visas for SAS programmers.

I think her question today provides an answer to all of these questions. She writes:

I need to read in about 500 character variables into SAS from an external file.

They are not generic: they have unique names with varying length.

Well, I can have somebody type in one after another. Any efficient way to read them in using Input statement? I do have all these files saved in an external CSV file.

Also, is there any way to avoid typing in $ sign in front of each variable to indicate to SAS that the variable is characgter? since all of them are character variables.

I made a test file C:\Junk\junk.csv:

"a","b","c" "abc","def","ghi" "???","Typists are cheaper than SAS programmers,"," but you get what you pay for."

to see what the problems are. Here is my program to read the file.

filename junk "c:\junk\junk.csv" ; data _null_ ; call execute ( "data w (compress=yes) ;" || " infile junk missover dsd firstobs = 2 ;" || " input " ) ;

infile junk obs = 1 missover dsd ; do while ( 1 ) ; input name :$char32. @ ; if name = "" then leave ; call execute ( name || ":$char1000." ) ; end ;

call execute ( "; run;" ) ; stop ; run ;

It is a bit crude, but provides the core idea for automating the task that Paula suggests. Now the interview questions might be

1) What is wrong with the SAS statement

input $ x ;

2) How would you handle the task suggested above? 3) Please explain features of the program above to me. 4) How would you parametrize this this code to read any csv file of character variables? 5) How would you use it to read hundreds of such files? 6) How would you improve the handling of the character lengths? 7) How would you change the code to expect some numeric variables?

If the candidate can handle all the questions, hire him/her. If the candidate can answer question 2 or any of the subsequent questions, he/she is probably worth hiring.

If the candidate can say something about #3 but also has problems with some things, then point him/her at the V8 online documentation and ask him/her to locate information about unknown features. If he/she shows facility with locating the information give him/her serious consideration. If he/she stumbles on question 1, ask about certification.

Ian Whitlock <whitloi1@westat.com>


Back to: Top of message | Previous page | Main SAS-L page