* here is my input data ;
123,"Harold Wilson",Acct,01/15/1989,$78,123.
128,"Julia Child",Food,08/29/1988,$89,123
007,"James Bond",Security,02/01/2000,$82,100
828,"Roger Doger",Acct,08/15/1999,$39,100
900,"Earl Davenport",Food,09/09/1989,$45,399
906,"James Swindler",Acct,12/21/1978,$78,200
* here is my output;
Obs |
id |
name |
dept |
HireDate |
Salary |
1 |
123 |
Harold Wilson |
Acct |
01/15/1989 |
$78 |
2 |
128 |
Julia Child |
Food |
08/29/1988 |
$89 |
3 |
7 |
James Bond |
Security |
02/01/2000 |
$82 |
4 |
828 |
Roger Doger |
Acct |
08/15/1999 |
$39 |
5 |
900 |
Earl Davenport |
Food |
09/09/1989 |
$45 |
6 |
906 |
James Swindler |
Acct |
12/21/1978 |
$78 |
as you can see, i am not able to get full salary value.
any idea what am i doing wrong here ?
here is my code....
data Employee;
infile'/folders/myfolders/Learning/employee.csv' dsd dlm=',' ;
input id : 3.
name : $20.
dept : $10.
HireDate : mmddyy10.
Salary : dollar10.;
format HireDate mmddyy10. Salary dollar10.;
run;
proc print data=employee;
run;
Your salary data contains commas that are also your delimiter. Removing the commas from your salary, or changing your delimiter will fix the problem.
This must be from a specific tutorial somewhere. This question is already answered on the forum elsewhere.
Another easy fix: just read in an extra variable.
input id : 3.
name : $20.
dept : $10.
HireDate : mmddyy10.
Salary : dollar10.
dollars;
if dollars > . then salary = salary * 1000 + dollars;
You might need to add to the INFILE statement (either TRUNCOVER or MISSOVER).
You are lucky, SALARY is the last column.
data Employee;
infile cards dsd dlm=',' truncover;
input id : 3.
name : $20.
dept : $10.
HireDate : mmddyy10.
Salary dollar10.;
format HireDate mmddyy10. Salary dollar10.;
cards;
123,"Harold Wilson",Acct,01/15/1989,$78,123
128,"Julia Child",Food,08/29/1988,$89,123
007,"James Bond",Security,02/01/2000,$82,100
828,"Roger Doger",Acct,08/15/1999,$39,100
900,"Earl Davenport",Food,09/09/1989,$45,399
906,"James Swindler",Acct,12/21/1978,$78,200
;
run;
proc print data=employee;
run;
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.
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.