As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.
Here are some tips for How to share your SAS knowledge with your professional network.
Hi user Darpnew,
In an April 2015 edit to Talk:Main Page you asked a question about problem with input statement. This question and its answers are being moved here instead of being lost in the discussion about the Main Page. The question and responses to it are reproduced below. - Cameron (talk) 02:27, 29 April 2017 (CDT)
Question: problem with input statement
I am new to SAS and facing difficulty to understand the below point: The below program is not giving correct output because the data after datalines statement is not following the spacing that is required as per variables defination in 'input' statement. Here, I have only 5 record lines and thus it is easy for me to change the spacing in datalines. But, if I have millions of records and data is coming as in current form (where the 'name' variable is having space in between, how would i define my 'input' statement so that output is correct as required. I tried using colon (:) in the input statement, but couldn't get the desired result. Please help!!
options pagesize=60 linesize=80 pageno=1 nodate; data sales; input EmployeeID $ 1-9 Name $ 11-29 @30 HireDate date9. Salary HomePhone $; format HireDate date9.; datalines; 429685482 Martin, Virginia 09aug1990 34800 493-0824 244967839 Singleton, MaryAnn 24apr1995 27900 929-2623 996740216 Leighton, Maurice 16dec1993 32600 933-6908 675443925 Freuler, Carl 15feb1998 29900 493-3993 845729308 Cage, Merce 19oct1992 39800 286-0519 ; proc print data=sales; title ’Sales Department Employees’; run;
- Darpnew Thank you for posting your question, although the site has a lot of information it really is not designed to be a discussion forum. Please consider posting your question to the Forums. These are designed to get the kind of response that you are hoping for. --Art Carpenter (talk) 13:37, 1 May 2015 (CDT)
Darpnew ... this will work .....
data sales_n; length EmployeeID $9. l_name f_name Salary HomePhone $12.; input EmployeeID $ l_name $ f_name $ HireDate date9. Salary $ HomePhone $; format HireDate date9.; Name= l_name||' '||f_name; datalines; 429685482 Martin, Virginia 09aug1990 34800 493-0824 244967839 Singleton, MaryAnn 24apr1995 27900 929-2623 996740216 Leighton, Maurice 16dec1993 32600 933-6908 675443925 Freuler, Carl 15feb1998 29900 493-3993 845729308 Cage, Merce 19oct1992 39800 286-0519 ; run; proc print data=sales_n; var EmployeeID Name Salary HomePhone HireDate ; title ’Sales Department Employees’; run; ’Sales Department Employees’ 1 12:39 Wednesday, August 19, 2015 Employee Home Obs ID Name Salary Phone HireDate 1 429685482 Martin, Virginia 34800 493-0824 09AUG1990 2 244967839 Singleton, MaryAnn 27900 929-2623 24APR1995 3 996740216 Leighton, Maurice 32600 933-6908 16DEC1993 4 675443925 Freuler, Carl 29900 493-3993 15FEB1998 5 845729308 Cage, Merce 39800 286-0519 19OCT1992
Lewis Goldson - email@example.com...