BookmarkSubscribeRSS Feed
rkshah333
Calcite | Level 5

* 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;
5 REPLIES 5
SASKiwi
PROC Star

Your salary data contains commas that are also your delimiter. Removing the commas from your salary, or changing your delimiter will fix the problem. 

Reeza
Super User

This must be from a specific tutorial somewhere. This question is already answered on the forum elsewhere.

 

https://communities.sas.com/t5/General-SAS-Programming/How-to-show-the-value-in/m-p/298454/highlight...

 

 

Astounding
PROC Star

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). 

Ksharp
Super User

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;      
rkshah333
Calcite | Level 5
Hi, Thanks it works, I appreciate for your help.


Rakesh


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
  • 5 replies
  • 2660 views
  • 0 likes
  • 5 in conversation