I have a table with multiple data rows for multiple variables. My issue is that some of the variables in some of the data rows are missing, and when I concate all the variables to one field, SAS assigns a different length to the missing values than to other values. I need my export to have the same exact placement of each variable (whether or not it is blank or not) but I cannot achieve this as the data rows with missing values take up less space than the other data rows. I have attached 2 pictures of what my output looks like, and what it should look like. My code is: /*LENGTH FORMATTING*/ DATA total_formated; set CVR_no_incl; Country1 = put(country,2.); Rcd_type1 = put(Rcd_type, 1.); char_dealer1 = put(left(char_dealer), 10.); char_Inv_nbr1 = put(left(char_Inv_nbr), 7.); char_Doc_type1 = put(right(char_Doc_type), 3.); char_Doc_date1 = put(right(char_Doc_date), 8.); char_Outstanding_amount1 = put(right(char_Outstanding_amount), 13.); char_Credit_limit1 = put(right(char_Credit_limit), 13.); run; /*REPLACES BLANKS WITHIN VARIABLES WITH & FOR CONCATE WITHOUT SPACES*/ Data And_instead_of_blank; set total_formated; Country1 = tranwrd(Country1, ' ', '&'); Rcd_type1 = tranwrd(Rcd_type1, ' ', '&'); char_dealer1 = tranwrd(char_dealer1, ' ', '&'); char_Inv_nbr1 = tranwrd(char_Inv_nbr1, ' ', '&'); char_Doc_type1 = tranwrd(char_Doc_type1, ' ', '&'); char_Doc_date1 = tranwrd(char_Doc_date1, ' ', '&'); char_Outstanding_amount1 = tranwrd(char_Outstanding_amount1, ' ', '&'); char_Credit_limit1 = tranwrd(char_Credit_limit1, ' ', '&'); run; Data Ready_for_concate; set And_instead_of_blank; length Country1 $2 Rcd_type1 $1 char_dealer1 $10 char_Inv_nbr1 $7 char_Doc_type1 $3 char_Doc_date1 $8 char_Outstanding_amount1 $13 char_Credit_limit1 $13; run; /*CONCATENATES TO A SINGLE STRING*/ PROC SQL; create table Concatenated as select cat(Country1, Rcd_type1, char_dealer1, char_Inv_nbr1, char_Doc_type1, char_Doc_date1, char_Outstanding_amount1, char_Credit_limit1) as Concatenated from Ready_for_concate; quit; /*REPLACES & WITH BLANKS IN CONCATENATED STRING WITHOUT SPACES/DELIMITERS*/ Data Ready_for_export; set Concatenated; Concatenated = tranwrd(Concatenated, '&', ' '); run; Can anyone help me? Thank you!
... View more