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

Hi All,

Sometimes when I hold the value of a variabe in SAS, I am unsure where to use the trailing @ as I get an error when reading other variables. I use this as an example:

Suppose I want to read this text tab delimited file:

Andrew Rapayer 45 61

Abbey Murrey 10 9

Tina Amber 10 20

I should hold the value of Andrew Rapayer and then read off the next two values using @. The code I use:

Data test;

infile "C:\SAS\test.txt" dlm = ' ';

input Name & : $15. @

        Age : 2.

        Height : 2.

;

run;

Since I am using dlm ='' option so each value is seperated by a space so when I read first obs from text file it would treat Andrew & Rapayer as seperate values but I want to input that as Name so I am using & to read this and then hold the value using @ but I get an error when reading the Age:

ERROR 22-232 : Expecting a Name.

Kindly advise what is the missing link.

Kind Regards

SK

1 ACCEPTED SOLUTION

Accepted Solutions
Scott_Mitchell
Quartz | Level 8

From what I understand, using the ampersand special character/modifier won't help you anyway.  When using this modifier SAS treats two or more spaces as the end of the string, which you don't have in your sample data.

View solution in original post

1 REPLY 1
Scott_Mitchell
Quartz | Level 8

From what I understand, using the ampersand special character/modifier won't help you anyway.  When using this modifier SAS treats two or more spaces as the end of the string, which you don't have in your sample data.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 665 views
  • 1 like
  • 2 in conversation