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!
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
EDIT:
Not sure why the new lines didn't carry over. For ease to view.
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
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
;
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.