Help using Base SAS procedures

holding SAS value using @

Accepted Solution Solved
Reply
Contributor
Posts: 57
Accepted Solution

holding SAS value using @

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


Accepted Solutions
Solution
‎08-13-2013 01:51 AM
Super Contributor
Posts: 297

Re: holding SAS value using @

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


All Replies
Solution
‎08-13-2013 01:51 AM
Super Contributor
Posts: 297

Re: holding SAS value using @

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.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 165 views
  • 1 like
  • 2 in conversation