BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Durlov
Obsidian | Level 7

 

data money;
infile datalines dlm='@';
input Name $ Salary DOLLAR12.2 Bonus DOLLAR12.2 Age;
datalines;
Harry@$50,000.00@$3,500.00@45
Larry@$30,000.00@$10,500.00@55
Jerry@$1,000,000.00@$100,500.00@21
;

proc print data = money;
run;
proc contents data=money;
run;

So I was running the above code and was expecting the '@' symbol to act as a delimiter, however that doesn't seem to be the case. Can someone help me UNDERSTAND what's wrong? Just to note, I'm just experimenting with SAS to get better at it. The output I get is below: 

Obs	Name	Salary	Bonus	Age
1	Harry	.	.	.
2	Larry	.	.	.
3	Jerry	1000000	.	0

Thanks much!!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

All you need is mixed input style

 

data money;
infile datalines dlm='@';
input Name $ Salary :DOLLAR12.2 Bonus :DOLLAR12.2 Age;
datalines;
Harry@$50,000.00@$3,500.00@45
Larry@$30,000.00@$10,500.00@55
Jerry@$1,000,000.00@$100,500.00@21
;

proc print data = money;
run;

when you prefix the informat with colon, the character field is extracted before the informat is applied.

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

All you need is mixed input style

 

data money;
infile datalines dlm='@';
input Name $ Salary :DOLLAR12.2 Bonus :DOLLAR12.2 Age;
datalines;
Harry@$50,000.00@$3,500.00@45
Larry@$30,000.00@$10,500.00@55
Jerry@$1,000,000.00@$100,500.00@21
;

proc print data = money;
run;

when you prefix the informat with colon, the character field is extracted before the informat is applied.

PG
Durlov
Obsidian | Level 7

Oh! Thanks! It's working as expected now.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 736 views
  • 0 likes
  • 2 in conversation