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

 

I pretty much just want these character values (I need the leading zero for merging and ordering), to be in a single column. I thought the @@ would allow me to write my list in a single row and still go in the correct column. However, I end up with an error instead, so maybe I misunderstood it's use. Is there a way to write this code without having to go the the next line after each value? 

/*Code Have*/
data devtype; input dvdecod@@; cards; '00' '01' '02' '03' '04' '05' '06' '07' '08' '09' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '99' ; run;

/*Code Trying to Avoid*/
data devtype;
 input dvdecod;
 cards;
 '00'
 '01'
 '02'
 '03'
 ...
;
run;

/*Log File Error - repeats*/
NOTE: Invalid data for DVDECOD in line 1001 2-5.
1001 '12' '13' '14' '15' '16' '17'
DVDECOD=- _ERROR_=1 _N_=13
NOTE: Invalid data for DVDECOD in line 1001 7-10.
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.

Thank you in advance!

 

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

Try this:

data devtype;
 input dvdecod @@;
 dvdecod_leading0 = put(dvdecod,z2.);
 dvdecod_leading0_quotes = "'"!! dvdecod_leading0 !! "'";
 cards;
 0  1  2  3  4  5
 6  7  8  9 10 11
12 13 14 15 16 17
18 19 99
;
run;
/* end of program */

Koen

View solution in original post

4 REPLIES 4
mariko5797
Pyrite | Level 9

EDIT: 

Not sure why the new lines didn't carry over. For ease to view.

mariko5797_0-1631549088177.png

 

sbxkoenk
SAS Super FREQ

Try this:

data devtype;
 input dvdecod @@;
 dvdecod_leading0 = put(dvdecod,z2.);
 dvdecod_leading0_quotes = "'"!! dvdecod_leading0 !! "'";
 cards;
 0  1  2  3  4  5
 6  7  8  9 10 11
12 13 14 15 16 17
18 19 99
;
run;
/* end of program */

Koen

Tom
Super User Tom
Super User

If you want leading zeros then read the values are text instead of numeric.

data devtype;
  input dvdecod $ @@;
cards;
00 01 02 03 04 05
06 07 08 09 10 11
12 13 14 15 16 17
18 19 99
;
PaigeMiller
Diamond | Level 26

If you want character values for DVDECOD, you have to specify that DVDECOD is character in the INPUT statement (by using a $ plus optional formatting) and do not enclose them in quotes.

 

data devtype;
 input dvdecod $ @@;
 cards;
 00 01 02 03 04 05
 06 07 08 09 10 11
 12 13 14 15 16 17
 18 19 99
 ;
run;
--
Paige Miller

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 903 views
  • 1 like
  • 4 in conversation