Hello all, im having issues with the INDSNAME column. It outputs as it should... however Im looking to make this column permanent so that I can rename the source names to more understandable terms. I tried using INDSNAME then using IF-THEN statements to rename the sources into a new column, however these sources get automatically removed once further querying the table.. is there any way for me to make INDSNAME a permanent column in the dataset?
data work.totaltable; set work.1222872-work.1222998 indsname=Dsnames; source=Dsnames; run; data totaltable; set work.totaltable; if source='work.1222872' then SourceTransc='Transaction 2287'; ......
run;
data totaltable; set work.totaltable; if source='work.1222872' then SourceTransc='Transaction 2287'; ...... run;
This type of coding is known to cause issues so it's a good idea to use a unique data set name between each data step, then you can trace your code for bugs.
Did you check the output of totaltable after the first step to ensure that the source variable is being created correctly and as expected? Usually character variables have a default length of 8 characters and your names are larger so it could be that. You need to add in a length statement for the source variable if that is the case.
Also, it's usually returned as all uppercase I believe and you're using lower case data, SAS is case sensitive for character comparisons.
@JibJam221 wrote:
Hello all, im having issues with the INDSNAME column. It outputs as it should... however Im looking to make this column permanent so that I can rename the source names to more understandable terms. I tried using INDSNAME then using IF-THEN statements to rename the sources into a new column, however these sources get automatically removed once further querying the table.. is there any way for me to make INDSNAME a permanent column in the dataset?
data work.totaltable; set work.1222872-work.1222998 indsname=Dsnames; source=Dsnames; run; data totaltable; set work.totaltable; if source='work.1222872' then SourceTransc='Transaction 2287'; ......
run;
data work.totaltable; set work.1222872-work.1222998 indsname=Dsnames; source=Dsnames; run; data work.totaltable2; set work.totaltable; if source='work.1222872' then SourceTransc='Transaction 2287'; ...... run; proc sql; create table work.FinalTable AS select SourceTransc, First_Name, Last_Name, .... from work.totaltable2; run;
Hello all,
im having issues with the INDSNAME column. It outputs as it should... however Im looking to make this column permanent so that I can rename the source names to more understandable terms. I tried using INDSNAME then using IF-THEN statements to rename the sources into a new column, however these sources get automatically removed once further querying the table..
is there any way for me to make INDSNAME a permanent column in the dataset?
Your first step cannot work.
This statement is not valid SAS syntax.
set work.1222872-work.1222998 indsname=Dsnames;
1222872 and 1222998 are not valid member names for SAS datasets.
If you have set the VALIDMEMNAME option to EXTEND then perhaps you could use
set work.'1222872'n-work.'1222998'n indsname=Dsnames;
Setting the VALIDMEMNAME option to EXTEND only means that SAS will ALLOW the use of the non-standard names.
To actually reference the datasets that have such names you will still need to use a NAME LITERAL in your code instead of normal syntax.
124 options validmemname=extend;
125 data work.123;
--------
22
201
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, /, ;, _DATA_, _LAST_, _NULL_.
ERROR 201-322: The option is not recognized and will be ignored.
126 x=2;
127 run;
You probably should add LENGTH statement(s) to make sure that the two variables you are using are long enough.
options validmemname=extend;
data work.'123'n '124'n;
x=2;
run;
data want;
length temporary permanent $70 ;
set work.'123'n - work.'124'n indsname=temporary ;
permanent=temporary;
run;
If the values are "disappearing" then add some diagnostic steps to see when they disappear.
@JibJam221 wrote:
hello! Thanks for letting me know, I didnt know that!
and the Source variable is working, its outputting the sources as i'd like to. Im just hoping to find a way for it to stay when I try to further query the table.
I'm confused. You said the source variable is working.
So is it working or not?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.